| 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" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 16 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| 17 #include "mojo/public/cpp/system/handle.h" | 17 #include "mojo/public/cpp/system/handle.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 |
| 21 class AssociatedGroupController; |
| 22 |
| 20 namespace internal { | 23 namespace internal { |
| 21 | 24 |
| 22 class MultiplexRouter; | |
| 23 | |
| 24 // A container for handles during serialization/deserialization. | 25 // A container for handles during serialization/deserialization. |
| 25 class SerializedHandleVector { | 26 class SerializedHandleVector { |
| 26 public: | 27 public: |
| 27 SerializedHandleVector(); | 28 SerializedHandleVector(); |
| 28 ~SerializedHandleVector(); | 29 ~SerializedHandleVector(); |
| 29 | 30 |
| 30 size_t size() const { return handles_.size(); } | 31 size_t size() const { return handles_.size(); } |
| 31 | 32 |
| 32 // Adds a handle to the handle list and returns its index for encoding. | 33 // Adds a handle to the handle list and returns its index for encoding. |
| 33 Handle_Data AddHandle(mojo::Handle handle); | 34 Handle_Data AddHandle(mojo::Handle handle); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 private: | 49 private: |
| 49 // Handles are owned by this object. | 50 // Handles are owned by this object. |
| 50 std::vector<mojo::Handle> handles_; | 51 std::vector<mojo::Handle> handles_; |
| 51 | 52 |
| 52 DISALLOW_COPY_AND_ASSIGN(SerializedHandleVector); | 53 DISALLOW_COPY_AND_ASSIGN(SerializedHandleVector); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 // Context information for serialization/deserialization routines. | 56 // Context information for serialization/deserialization routines. |
| 56 struct SerializationContext { | 57 struct SerializationContext { |
| 57 SerializationContext(); | 58 SerializationContext(); |
| 58 explicit SerializationContext(scoped_refptr<MultiplexRouter> in_router); | 59 explicit SerializationContext( |
| 60 scoped_refptr<AssociatedGroupController> in_group_controller); |
| 59 | 61 |
| 60 ~SerializationContext(); | 62 ~SerializationContext(); |
| 61 | 63 |
| 62 // Used to serialize/deserialize associated interface pointers and requests. | 64 // Used to serialize/deserialize associated interface pointers and requests. |
| 63 scoped_refptr<MultiplexRouter> router; | 65 scoped_refptr<AssociatedGroupController> group_controller; |
| 64 | 66 |
| 65 // Opaque context pointers returned by StringTraits::SetUpContext(). | 67 // Opaque context pointers returned by StringTraits::SetUpContext(). |
| 66 std::unique_ptr<std::queue<void*>> custom_contexts; | 68 std::unique_ptr<std::queue<void*>> custom_contexts; |
| 67 | 69 |
| 68 // Stashes handles encoded in a message by index. | 70 // Stashes handles encoded in a message by index. |
| 69 SerializedHandleVector handles; | 71 SerializedHandleVector handles; |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 } // namespace internal | 74 } // namespace internal |
| 73 } // namespace mojo | 75 } // namespace mojo |
| 74 | 76 |
| 75 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_CONTEXT_H_ | 77 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_CONTEXT_H_ |
| OLD | NEW |