Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_SERIALIZATION_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| 11 #include "mojo/public/cpp/system/core.h" | 11 #include "mojo/public/cpp/system/core.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 | 14 |
| 15 template <typename I> | 15 template <typename I> |
| 16 class InterfacePtr; | 16 class InterfacePtr; |
| 17 | 17 |
| 18 template <typename I> | 18 template <typename I> |
| 19 class InterfacePtrInfo; | 19 class InterfaceHandle; |
| 20 | 20 |
| 21 namespace internal { | 21 namespace internal { |
| 22 | 22 |
| 23 // Please note that this is a different value than |mojo::kInvalidHandleValue|, | 23 // Please note that this is a different value than |mojo::kInvalidHandleValue|, |
| 24 // which is the "decoded" invalid handle. | 24 // which is the "decoded" invalid handle. |
| 25 const MojoHandle kEncodedInvalidHandleValue = static_cast<MojoHandle>(-1); | 25 const MojoHandle kEncodedInvalidHandleValue = static_cast<MojoHandle>(-1); |
| 26 | 26 |
| 27 size_t Align(size_t size); | 27 size_t Align(size_t size); |
| 28 char* AlignPointer(char* ptr); | 28 char* AlignPointer(char* ptr); |
| 29 | 29 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 template <typename T> | 72 template <typename T> |
| 73 inline void Decode(T* obj, std::vector<Handle>* handles) { | 73 inline void Decode(T* obj, std::vector<Handle>* handles) { |
| 74 DecodePointer(&obj->offset, &obj->ptr); | 74 DecodePointer(&obj->offset, &obj->ptr); |
| 75 if (obj->ptr) | 75 if (obj->ptr) |
| 76 obj->ptr->DecodePointersAndHandles(handles); | 76 obj->ptr->DecodePointersAndHandles(handles); |
| 77 } | 77 } |
| 78 | 78 |
| 79 template <typename T> | 79 template <typename T> |
| 80 inline void InterfacePointerToData(InterfacePtr<T> input, | 80 inline void InterfacePointerToData(InterfacePtr<T> input, |
| 81 Interface_Data* output) { | 81 Interface_Data* output) { |
| 82 InterfacePtrInfo<T> info = input.PassInterface(); | 82 InterfaceHandle<T> info = input.PassInterface(); |
|
jamesr
2016/02/03 22:42:57
it's weird that PassInterface() returns a Interfac
| |
| 83 output->handle = info.PassHandle().release(); | 83 output->handle = info.PassHandle().release(); |
| 84 output->version = info.version(); | 84 output->version = info.version(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 template <typename T> | 87 template <typename T> |
| 88 inline void InterfaceDataToPointer(Interface_Data* input, | 88 inline void InterfaceDataToPointer(Interface_Data* input, |
| 89 InterfacePtr<T>* output) { | 89 InterfacePtr<T>* output) { |
| 90 output->Bind(InterfacePtrInfo<T>( | 90 output->Bind(InterfaceHandle<T>( |
| 91 MakeScopedHandle(FetchAndReset(&input->handle)), input->version)); | 91 MakeScopedHandle(FetchAndReset(&input->handle)), input->version)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace internal | 94 } // namespace internal |
| 95 } // namespace mojo | 95 } // namespace mojo |
| 96 | 96 |
| 97 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ | 97 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ |
| OLD | NEW |