| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_BINDER_WRITABLE_TRANSACTION_DATA_H_ | 5 #ifndef CHROMEOS_BINDER_WRITABLE_TRANSACTION_DATA_H_ |
| 6 #define CHROMEOS_BINDER_WRITABLE_TRANSACTION_DATA_H_ | 6 #define CHROMEOS_BINDER_WRITABLE_TRANSACTION_DATA_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "chromeos/binder/transaction_data.h" | 14 #include "chromeos/binder/transaction_data.h" |
| 13 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
| 14 | 16 |
| 15 namespace binder { | 17 namespace binder { |
| 16 | 18 |
| 17 // Use this class to construct TransactionData (as parameters and replies) to | 19 // Use this class to construct TransactionData (as parameters and replies) to |
| 18 // transact with remote objects. | 20 // transact with remote objects. |
| 19 // GetSenderPID() and GetSenderEUID() return 0. | 21 // GetSenderPID() and GetSenderEUID() return 0. |
| 20 class CHROMEOS_EXPORT WritableTransactionData : public TransactionData { | 22 class CHROMEOS_EXPORT WritableTransactionData : public TransactionData { |
| 21 public: | 23 public: |
| 22 WritableTransactionData(); | 24 WritableTransactionData(); |
| 23 ~WritableTransactionData() override; | 25 ~WritableTransactionData() override; |
| 24 | 26 |
| 25 // TransactionData override: | 27 // TransactionData override: |
| 26 uintptr_t GetCookie() const override; | 28 uintptr_t GetCookie() const override; |
| 27 uint32 GetCode() const override; | 29 uint32_t GetCode() const override; |
| 28 pid_t GetSenderPID() const override; | 30 pid_t GetSenderPID() const override; |
| 29 uid_t GetSenderEUID() const override; | 31 uid_t GetSenderEUID() const override; |
| 30 bool IsOneWay() const override; | 32 bool IsOneWay() const override; |
| 31 bool HasStatus() const override; | 33 bool HasStatus() const override; |
| 32 Status GetStatus() const override; | 34 Status GetStatus() const override; |
| 33 const void* GetData() const override; | 35 const void* GetData() const override; |
| 34 size_t GetDataSize() const override; | 36 size_t GetDataSize() const override; |
| 35 const uintptr_t* GetObjectOffsets() const override; | 37 const uintptr_t* GetObjectOffsets() const override; |
| 36 size_t GetNumObjectOffsets() const override; | 38 size_t GetNumObjectOffsets() const override; |
| 37 | 39 |
| 38 // Expands the capacity of the internal buffer. | 40 // Expands the capacity of the internal buffer. |
| 39 void Reserve(size_t n); | 41 void Reserve(size_t n); |
| 40 | 42 |
| 41 // Sets the transaction code returned by GetCode(). | 43 // Sets the transaction code returned by GetCode(). |
| 42 void SetCode(uint32 code) { code_ = code; } | 44 void SetCode(uint32_t code) { code_ = code; } |
| 43 | 45 |
| 44 // Sets the value returned by IsOneWay(). | 46 // Sets the value returned by IsOneWay(). |
| 45 void SetIsOneWay(bool is_one_way) { is_one_way_ = is_one_way; } | 47 void SetIsOneWay(bool is_one_way) { is_one_way_ = is_one_way; } |
| 46 | 48 |
| 47 // Appends the specified data with appropriate padding. | 49 // Appends the specified data with appropriate padding. |
| 48 void WriteData(const void* data, size_t n); | 50 void WriteData(const void* data, size_t n); |
| 49 | 51 |
| 50 // Appends an int32 value. | 52 // Appends an int32_t value. |
| 51 void WriteInt32(int32 value); | 53 void WriteInt32(int32_t value); |
| 52 | 54 |
| 53 // Appends a uint32 value. | 55 // Appends a uint32_t value. |
| 54 void WriteUint32(uint32 value); | 56 void WriteUint32(uint32_t value); |
| 55 | 57 |
| 56 // Appends an int64 vlaue. | 58 // Appends an int64_t vlaue. |
| 57 void WriteInt64(int64 value); | 59 void WriteInt64(int64_t value); |
| 58 | 60 |
| 59 // Appends a uint64 value. | 61 // Appends a uint64_t value. |
| 60 void WriteUint64(uint64 value); | 62 void WriteUint64(uint64_t value); |
| 61 | 63 |
| 62 // Appends a float value. | 64 // Appends a float value. |
| 63 void WriteFloat(float value); | 65 void WriteFloat(float value); |
| 64 | 66 |
| 65 // Appends a double value. | 67 // Appends a double value. |
| 66 void WriteDouble(double value); | 68 void WriteDouble(double value); |
| 67 // TODO(hashimoto): Support more types (i.e. strings, FDs, objects). | 69 // TODO(hashimoto): Support more types (i.e. strings, FDs, objects). |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 uint32 code_ = 0; | 72 uint32_t code_ = 0; |
| 71 bool is_one_way_ = false; | 73 bool is_one_way_ = false; |
| 72 std::vector<char> data_; | 74 std::vector<char> data_; |
| 73 std::vector<uintptr_t> object_offsets_; | 75 std::vector<uintptr_t> object_offsets_; |
| 74 | 76 |
| 75 DISALLOW_COPY_AND_ASSIGN(WritableTransactionData); | 77 DISALLOW_COPY_AND_ASSIGN(WritableTransactionData); |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 } // namespace binder | 80 } // namespace binder |
| 79 | 81 |
| 80 #endif // CHROMEOS_BINDER_WRITABLE_TRANSACTION_DATA_H_ | 82 #endif // CHROMEOS_BINDER_WRITABLE_TRANSACTION_DATA_H_ |
| OLD | NEW |