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