Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: mojo/public/cpp/bindings/lib/bindings_internal.h

Issue 2660733002: Mojo C++ bindings: introduce an optional array to store transferred interface IDs in messages. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <functional> 10 #include <functional>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 T* Get() { 117 T* Get() {
118 return static_cast<T*>(const_cast<void*>(DecodePointer(&offset))); 118 return static_cast<T*>(const_cast<void*>(DecodePointer(&offset)));
119 } 119 }
120 120
121 bool is_null() const { return offset == 0; } 121 bool is_null() const { return offset == 0; }
122 122
123 uint64_t offset; 123 uint64_t offset;
124 }; 124 };
125 static_assert(sizeof(Pointer<char>) == 8, "Bad_sizeof(Pointer)"); 125 static_assert(sizeof(Pointer<char>) == 8, "Bad_sizeof(Pointer)");
126 126
127 using GenericPointer = Pointer<void>;
128
127 struct Handle_Data { 129 struct Handle_Data {
128 Handle_Data() = default; 130 Handle_Data() = default;
129 explicit Handle_Data(uint32_t value) : value(value) {} 131 explicit Handle_Data(uint32_t value) : value(value) {}
130 132
131 bool is_valid() const { return value != kEncodedInvalidHandleValue; } 133 bool is_valid() const { return value != kEncodedInvalidHandleValue; }
132 134
133 uint32_t value; 135 uint32_t value;
134 }; 136 };
135 static_assert(sizeof(Handle_Data) == 4, "Bad_sizeof(Handle_Data)"); 137 static_assert(sizeof(Handle_Data) == 4, "Bad_sizeof(Handle_Data)");
136 138
137 struct Interface_Data { 139 struct Interface_Data {
138 Handle_Data handle; 140 Handle_Data handle;
139 uint32_t version; 141 uint32_t version;
140 }; 142 };
141 static_assert(sizeof(Interface_Data) == 8, "Bad_sizeof(Interface_Data)"); 143 static_assert(sizeof(Interface_Data) == 8, "Bad_sizeof(Interface_Data)");
142 144
145 struct AssociatedEndpointHandle_Data {
146 AssociatedEndpointHandle_Data() = default;
147 explicit AssociatedEndpointHandle_Data(uint32_t value) : value(value) {}
148
149 bool is_valid() const { return value != kEncodedInvalidHandleValue; }
150
151 uint32_t value;
152 };
153 static_assert(sizeof(AssociatedEndpointHandle_Data) == 4,
154 "Bad_sizeof(AssociatedEndpointHandle_Data)");
155
143 struct AssociatedInterface_Data { 156 struct AssociatedInterface_Data {
144 InterfaceId interface_id; 157 AssociatedEndpointHandle_Data handle;
145 uint32_t version; 158 uint32_t version;
146 }; 159 };
147 static_assert(sizeof(AssociatedInterface_Data) == 8, 160 static_assert(sizeof(AssociatedInterface_Data) == 8,
148 "Bad_sizeof(AssociatedInterface_Data)"); 161 "Bad_sizeof(AssociatedInterface_Data)");
149 162
150 struct AssociatedInterfaceRequest_Data {
151 InterfaceId interface_id;
152 };
153 static_assert(sizeof(AssociatedInterfaceRequest_Data) == 4,
154 "Bad_sizeof(AssociatedInterfaceRequest_Data)");
155
156 #pragma pack(pop) 163 #pragma pack(pop)
157 164
158 template <typename T> 165 template <typename T>
159 T FetchAndReset(T* ptr) { 166 T FetchAndReset(T* ptr) {
160 T temp = *ptr; 167 T temp = *ptr;
161 *ptr = T(); 168 *ptr = T();
162 return temp; 169 return temp;
163 } 170 }
164 171
165 template <typename T> 172 template <typename T>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 struct MojomTypeTraits<AssociatedInterfacePtrInfoDataView<T>, false> { 234 struct MojomTypeTraits<AssociatedInterfacePtrInfoDataView<T>, false> {
228 using Data = AssociatedInterface_Data; 235 using Data = AssociatedInterface_Data;
229 using DataAsArrayElement = Data; 236 using DataAsArrayElement = Data;
230 237
231 static const MojomTypeCategory category = 238 static const MojomTypeCategory category =
232 MojomTypeCategory::ASSOCIATED_INTERFACE; 239 MojomTypeCategory::ASSOCIATED_INTERFACE;
233 }; 240 };
234 241
235 template <typename T> 242 template <typename T>
236 struct MojomTypeTraits<AssociatedInterfaceRequestDataView<T>, false> { 243 struct MojomTypeTraits<AssociatedInterfaceRequestDataView<T>, false> {
237 using Data = AssociatedInterfaceRequest_Data; 244 using Data = AssociatedEndpointHandle_Data;
238 using DataAsArrayElement = Data; 245 using DataAsArrayElement = Data;
239 246
240 static const MojomTypeCategory category = 247 static const MojomTypeCategory category =
241 MojomTypeCategory::ASSOCIATED_INTERFACE_REQUEST; 248 MojomTypeCategory::ASSOCIATED_INTERFACE_REQUEST;
242 }; 249 };
243 250
244 template <> 251 template <>
245 struct MojomTypeTraits<bool, false> { 252 struct MojomTypeTraits<bool, false> {
246 using Data = bool; 253 using Data = bool;
247 using DataAsArrayElement = Data; 254 using DataAsArrayElement = Data;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 size_t operator()(T input) const { 327 size_t operator()(T input) const {
321 using UnderlyingType = typename base::underlying_type<T>::type; 328 using UnderlyingType = typename base::underlying_type<T>::type;
322 return std::hash<UnderlyingType>()(static_cast<UnderlyingType>(input)); 329 return std::hash<UnderlyingType>()(static_cast<UnderlyingType>(input));
323 } 330 }
324 }; 331 };
325 332
326 } // namespace internal 333 } // namespace internal
327 } // namespace mojo 334 } // namespace mojo
328 335
329 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ 336 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/binding_state.h ('k') | mojo/public/cpp/bindings/lib/control_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698