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_EDK_SYSTEM_TRANSPORT_DATA_H_ | 5 #ifndef MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ |
6 #define MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ | 6 #define MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 static const size_t kMaxSerializedDispatcherPlatformHandles = 2; | 84 static const size_t kMaxSerializedDispatcherPlatformHandles = 2; |
85 | 85 |
86 // The maximum possible size of a valid transport data buffer. | 86 // The maximum possible size of a valid transport data buffer. |
87 static size_t GetMaxBufferSize(); | 87 static size_t GetMaxBufferSize(); |
88 | 88 |
89 // The maximum total number of platform handles that may be attached. | 89 // The maximum total number of platform handles that may be attached. |
90 static size_t GetMaxPlatformHandles(); | 90 static size_t GetMaxPlatformHandles(); |
91 | 91 |
92 TransportData(scoped_ptr<DispatcherVector> dispatchers, Channel* channel); | 92 TransportData(scoped_ptr<DispatcherVector> dispatchers, Channel* channel); |
93 | 93 |
94 #if defined(OS_POSIX) | 94 // This is used for users of |MessageInTransit|/|TransportData|/|RawChannel| |
95 // This is a hacky POSIX-only constructor to directly attach only platform | 95 // that want to simply transport data and platform handles, and not |
96 // handles to a message, used by |RawChannelPosix| to split messages with too | 96 // |Dispatcher|s. (|Header| will be present, and zero except for |
97 // many platform handles into multiple messages. |Header| will be present, but | 97 // |num_platform_handles|, and |platform_handle_table_offset| if necessary.) |
98 // be zero. (No other information will be attached, and | |
99 // |RawChannel::GetSerializedPlatformHandleSize()| should return zero.) | |
100 explicit TransportData( | 98 explicit TransportData( |
101 embedder::ScopedPlatformHandleVectorPtr platform_handles); | 99 embedder::ScopedPlatformHandleVectorPtr platform_handles); |
102 #endif | |
103 | 100 |
104 ~TransportData(); | 101 ~TransportData(); |
105 | 102 |
106 const void* buffer() const { return buffer_.get(); } | 103 const void* buffer() const { return buffer_.get(); } |
107 void* buffer() { return buffer_.get(); } | 104 void* buffer() { return buffer_.get(); } |
108 size_t buffer_size() const { return buffer_size_; } | 105 size_t buffer_size() const { return buffer_size_; } |
109 | 106 |
110 uint32_t platform_handle_table_offset() const { | 107 uint32_t platform_handle_table_offset() const { |
111 return header()->platform_handle_table_offset; | 108 return header()->platform_handle_table_offset; |
112 } | 109 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 const Header* header() const { | 170 const Header* header() const { |
174 return reinterpret_cast<const Header*>(buffer_.get()); | 171 return reinterpret_cast<const Header*>(buffer_.get()); |
175 } | 172 } |
176 | 173 |
177 size_t buffer_size_; | 174 size_t buffer_size_; |
178 scoped_ptr<char, base::AlignedFreeDeleter> buffer_; // Never null. | 175 scoped_ptr<char, base::AlignedFreeDeleter> buffer_; // Never null. |
179 | 176 |
180 // Any platform-specific handles attached to this message (for inter-process | 177 // Any platform-specific handles attached to this message (for inter-process |
181 // transport). The vector (if any) owns the handles that it contains (and is | 178 // transport). The vector (if any) owns the handles that it contains (and is |
182 // responsible for closing them). | 179 // responsible for closing them). |
183 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandles|. | 180 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandle|s. |
184 embedder::ScopedPlatformHandleVectorPtr platform_handles_; | 181 embedder::ScopedPlatformHandleVectorPtr platform_handles_; |
185 | 182 |
186 DISALLOW_COPY_AND_ASSIGN(TransportData); | 183 DISALLOW_COPY_AND_ASSIGN(TransportData); |
187 }; | 184 }; |
188 | 185 |
189 } // namespace system | 186 } // namespace system |
190 } // namespace mojo | 187 } // namespace mojo |
191 | 188 |
192 #endif // MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ | 189 #endif // MOJO_EDK_SYSTEM_TRANSPORT_DATA_H_ |
OLD | NEW |