OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SYSTEM_TRANSPORT_DATA_H_ | 5 #ifndef MOJO_SYSTEM_TRANSPORT_DATA_H_ |
6 #define MOJO_SYSTEM_TRANSPORT_DATA_H_ | 6 #define MOJO_SYSTEM_TRANSPORT_DATA_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 class MOJO_SYSTEM_IMPL_EXPORT TransportData { | 72 class MOJO_SYSTEM_IMPL_EXPORT TransportData { |
73 public: | 73 public: |
74 // The maximum size of a single serialized dispatcher. This must be a multiple | 74 // The maximum size of a single serialized dispatcher. This must be a multiple |
75 // of |kMessageAlignment|. | 75 // of |kMessageAlignment|. |
76 static const size_t kMaxSerializedDispatcherSize = 10000; | 76 static const size_t kMaxSerializedDispatcherSize = 10000; |
77 | 77 |
78 // The maximum number of platform handles to attach for a single serialized | 78 // The maximum number of platform handles to attach for a single serialized |
79 // dispatcher. | 79 // dispatcher. |
80 static const size_t kMaxSerializedDispatcherPlatformHandles = 2; | 80 static const size_t kMaxSerializedDispatcherPlatformHandles = 2; |
81 | 81 |
82 TransportData( | 82 TransportData(scoped_ptr<DispatcherVector> dispatchers, Channel* channel); |
83 scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers, | |
84 Channel* channel); | |
85 ~TransportData(); | 83 ~TransportData(); |
86 | 84 |
87 const void* buffer() const { return buffer_.get(); } | 85 const void* buffer() const { return buffer_.get(); } |
88 size_t buffer_size() const { return buffer_size_; } | 86 size_t buffer_size() const { return buffer_size_; } |
89 | 87 |
90 // Gets attached platform-specific handles; this may return null if there are | 88 // Gets attached platform-specific handles; this may return null if there are |
91 // none. Note that the caller may mutate the set of platform-specific handles. | 89 // none. Note that the caller may mutate the set of platform-specific handles. |
92 std::vector<embedder::PlatformHandle>* platform_handles() { | 90 std::vector<embedder::PlatformHandle>* platform_handles() { |
93 return platform_handles_.get(); | 91 return platform_handles_.get(); |
94 } | 92 } |
(...skipping 10 matching lines...) Expand all Loading... |
105 // nonzero.) Returns null if valid, and a pointer to a human-readable error | 103 // nonzero.) Returns null if valid, and a pointer to a human-readable error |
106 // message (for debug/logging purposes) on error. Note: This checks the | 104 // message (for debug/logging purposes) on error. Note: This checks the |
107 // validity of the handle table entries (i.e., does range checking), but does | 105 // validity of the handle table entries (i.e., does range checking), but does |
108 // not check that the validity of the actual serialized dispatcher | 106 // not check that the validity of the actual serialized dispatcher |
109 // information. | 107 // information. |
110 static const char* ValidateBuffer(const void* buffer, size_t buffer_size); | 108 static const char* ValidateBuffer(const void* buffer, size_t buffer_size); |
111 | 109 |
112 // Deserializes dispatchers from the given (serialized) transport data buffer | 110 // Deserializes dispatchers from the given (serialized) transport data buffer |
113 // (typically from a |MessageInTransit::View|). |buffer| should be non-null | 111 // (typically from a |MessageInTransit::View|). |buffer| should be non-null |
114 // and |buffer_size| should be nonzero. | 112 // and |buffer_size| should be nonzero. |
115 static scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > | 113 static scoped_ptr<DispatcherVector> DeserializeDispatchersFromBuffer( |
116 DeserializeDispatchersFromBuffer(const void* buffer, | 114 const void* buffer, |
117 size_t buffer_size, | 115 size_t buffer_size, |
118 Channel* channel); | 116 Channel* channel); |
119 | 117 |
120 private: | 118 private: |
121 // To allow us to make compile-assertions about |Header|, etc. in the .cc | 119 // To allow us to make compile-assertions about |Header|, etc. in the .cc |
122 // file. | 120 // file. |
123 struct PrivateStructForCompileAsserts; | 121 struct PrivateStructForCompileAsserts; |
124 | 122 |
125 // Header for the "secondary buffer"/"transport data". Must be a multiple of | 123 // Header for the "secondary buffer"/"transport data". Must be a multiple of |
126 // |MessageInTransit::kMessageAlignment| in size. Must be POD. | 124 // |MessageInTransit::kMessageAlignment| in size. Must be POD. |
127 struct Header { | 125 struct Header { |
128 uint32_t num_handles; | 126 uint32_t num_handles; |
(...skipping 25 matching lines...) Expand all Loading... |
154 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandles|. | 152 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandles|. |
155 scoped_ptr<std::vector<embedder::PlatformHandle> > platform_handles_; | 153 scoped_ptr<std::vector<embedder::PlatformHandle> > platform_handles_; |
156 | 154 |
157 DISALLOW_COPY_AND_ASSIGN(TransportData); | 155 DISALLOW_COPY_AND_ASSIGN(TransportData); |
158 }; | 156 }; |
159 | 157 |
160 } // namespace system | 158 } // namespace system |
161 } // namespace mojo | 159 } // namespace mojo |
162 | 160 |
163 #endif // MOJO_SYSTEM_TRANSPORT_DATA_H_ | 161 #endif // MOJO_SYSTEM_TRANSPORT_DATA_H_ |
OLD | NEW |