hashimoto | 8079ea6 | 2015-12-16 05:40:39 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
hashimoto | 32e9f8bb | 2015-12-18 08:06:12 | [diff] [blame] | 5 | #ifndef CHROMEOS_BINDER_TRANSACTION_DATA_FROM_DRIVER_H_ |
| 6 | #define CHROMEOS_BINDER_TRANSACTION_DATA_FROM_DRIVER_H_ |
hashimoto | 8079ea6 | 2015-12-16 05:40:39 | [diff] [blame] | 7 | |
avi | 6e1a22d | 2015-12-21 03:43:20 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
hashimoto | 87353a3e | 2016-01-06 06:43:02 | [diff] [blame] | 10 | #include <sys/types.h> |
| 11 | |
| 12 | #include <linux/android/binder.h> |
hashimoto | 8079ea6 | 2015-12-16 05:40:39 | [diff] [blame] | 13 | |
| 14 | #include "base/callback.h" |
| 15 | #include "base/macros.h" |
| 16 | #include "base/memory/ref_counted.h" |
| 17 | #include "chromeos/binder/transaction_data.h" |
hashimoto | 32e9f8bb | 2015-12-18 08:06:12 | [diff] [blame] | 18 | #include "chromeos/chromeos_export.h" |
hashimoto | 8079ea6 | 2015-12-16 05:40:39 | [diff] [blame] | 19 | |
| 20 | namespace base { |
| 21 | class SingleThreadTaskRunner; |
| 22 | } |
| 23 | |
| 24 | namespace binder { |
| 25 | |
hashimoto | 8079ea6 | 2015-12-16 05:40:39 | [diff] [blame] | 26 | // TransactionData passed by the driver, whose data needs to be freed with |
| 27 | // BC_FREE_BUFFER command. |
hashimoto | 32e9f8bb | 2015-12-18 08:06:12 | [diff] [blame] | 28 | class CHROMEOS_EXPORT TransactionDataFromDriver : public TransactionData { |
hashimoto | 8079ea6 | 2015-12-16 05:40:39 | [diff] [blame] | 29 | public: |
| 30 | typedef base::Callback<void(const void* ptr)> BufferDeleter; |
| 31 | explicit TransactionDataFromDriver(const BufferDeleter& buffer_deleter); |
| 32 | ~TransactionDataFromDriver() override; |
| 33 | |
| 34 | const binder_transaction_data& data() const { return data_; } |
| 35 | binder_transaction_data* mutable_data() { return &data_; } |
| 36 | |
| 37 | // TransactionData override: |
| 38 | uintptr_t GetCookie() const override; |
avi | 6e1a22d | 2015-12-21 03:43:20 | [diff] [blame] | 39 | uint32_t GetCode() const override; |
hashimoto | 8079ea6 | 2015-12-16 05:40:39 | [diff] [blame] | 40 | pid_t GetSenderPID() const override; |
| 41 | uid_t GetSenderEUID() const override; |
| 42 | bool IsOneWay() const override; |
| 43 | bool HasStatus() const override; |
| 44 | Status GetStatus() const override; |
| 45 | const void* GetData() const override; |
| 46 | size_t GetDataSize() const override; |
| 47 | const uintptr_t* GetObjectOffsets() const override; |
| 48 | size_t GetNumObjectOffsets() const override; |
| 49 | |
| 50 | private: |
| 51 | scoped_refptr<base::SingleThreadTaskRunner> delete_task_runner_; |
| 52 | BufferDeleter buffer_deleter_; |
| 53 | binder_transaction_data data_; |
| 54 | |
| 55 | DISALLOW_COPY_AND_ASSIGN(TransactionDataFromDriver); |
| 56 | }; |
| 57 | |
| 58 | } // namespace binder |
| 59 | |
hashimoto | 32e9f8bb | 2015-12-18 08:06:12 | [diff] [blame] | 60 | #endif // CHROMEOS_BINDER_TRANSACTION_DATA_FROM_DRIVER_H_ |