| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CONTEXT_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_CONTEXT_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_CONTEXT_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | |
| 16 #include "mojo/public/cpp/bindings/bindings_export.h" | 15 #include "mojo/public/cpp/bindings/bindings_export.h" |
| 17 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 16 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| 17 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
| 18 #include "mojo/public/cpp/system/handle.h" | 18 #include "mojo/public/cpp/system/handle.h" |
| 19 | 19 |
| 20 namespace mojo { | 20 namespace mojo { |
| 21 | |
| 22 class AssociatedGroupController; | |
| 23 | |
| 24 namespace internal { | 21 namespace internal { |
| 25 | 22 |
| 26 // A container for handles during serialization/deserialization. | 23 // A container for handles during serialization/deserialization. |
| 27 class MOJO_CPP_BINDINGS_EXPORT SerializedHandleVector { | 24 class MOJO_CPP_BINDINGS_EXPORT SerializedHandleVector { |
| 28 public: | 25 public: |
| 29 SerializedHandleVector(); | 26 SerializedHandleVector(); |
| 30 ~SerializedHandleVector(); | 27 ~SerializedHandleVector(); |
| 31 | 28 |
| 32 size_t size() const { return handles_.size(); } | 29 size_t size() const { return handles_.size(); } |
| 33 | 30 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 private: | 47 private: |
| 51 // Handles are owned by this object. | 48 // Handles are owned by this object. |
| 52 std::vector<mojo::Handle> handles_; | 49 std::vector<mojo::Handle> handles_; |
| 53 | 50 |
| 54 DISALLOW_COPY_AND_ASSIGN(SerializedHandleVector); | 51 DISALLOW_COPY_AND_ASSIGN(SerializedHandleVector); |
| 55 }; | 52 }; |
| 56 | 53 |
| 57 // Context information for serialization/deserialization routines. | 54 // Context information for serialization/deserialization routines. |
| 58 struct MOJO_CPP_BINDINGS_EXPORT SerializationContext { | 55 struct MOJO_CPP_BINDINGS_EXPORT SerializationContext { |
| 59 SerializationContext(); | 56 SerializationContext(); |
| 60 explicit SerializationContext( | |
| 61 scoped_refptr<AssociatedGroupController> in_group_controller); | |
| 62 | 57 |
| 63 ~SerializationContext(); | 58 ~SerializationContext(); |
| 64 | 59 |
| 65 // Used to serialize/deserialize associated interface pointers and requests. | |
| 66 scoped_refptr<AssociatedGroupController> group_controller; | |
| 67 | |
| 68 // Opaque context pointers returned by StringTraits::SetUpContext(). | 60 // Opaque context pointers returned by StringTraits::SetUpContext(). |
| 69 std::unique_ptr<std::queue<void*>> custom_contexts; | 61 std::unique_ptr<std::queue<void*>> custom_contexts; |
| 70 | 62 |
| 71 // Stashes handles encoded in a message by index. | 63 // Stashes handles encoded in a message by index. |
| 72 SerializedHandleVector handles; | 64 SerializedHandleVector handles; |
| 65 |
| 66 // The number of ScopedInterfaceEndpointHandles that need to be serialized. |
| 67 // It is calculated by PrepareToSerialize(). |
| 68 uint32_t associated_endpoint_count = 0; |
| 69 |
| 70 // Stashes ScopedInterfaceEndpointHandles encoded in a message by index. |
| 71 std::vector<ScopedInterfaceEndpointHandle> associated_endpoint_handles; |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 } // namespace internal | 74 } // namespace internal |
| 76 } // namespace mojo | 75 } // namespace mojo |
| 77 | 76 |
| 78 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_CONTEXT_H_ | 77 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_CONTEXT_H_ |
| OLD | NEW |