| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MESSAGE_IN_TRANSIT_H_ | 5 #ifndef MOJO_SYSTEM_MESSAGE_IN_TRANSIT_H_ |
| 6 #define MOJO_SYSTEM_MESSAGE_IN_TRANSIT_H_ | 6 #define MOJO_SYSTEM_MESSAGE_IN_TRANSIT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 static const EndpointId kInvalidEndpointId = 0; | 63 static const EndpointId kInvalidEndpointId = 0; |
| 64 | 64 |
| 65 // Messages (the header and data) must always be aligned to a multiple of this | 65 // Messages (the header and data) must always be aligned to a multiple of this |
| 66 // quantity (which must be a power of 2). | 66 // quantity (which must be a power of 2). |
| 67 static const size_t kMessageAlignment = 8; | 67 static const size_t kMessageAlignment = 8; |
| 68 | 68 |
| 69 // The maximum size of a single serialized dispatcher. This must be a multiple | 69 // The maximum size of a single serialized dispatcher. This must be a multiple |
| 70 // of |kMessageAlignment|. | 70 // of |kMessageAlignment|. |
| 71 static const size_t kMaxSerializedDispatcherSize = 10000; | 71 static const size_t kMaxSerializedDispatcherSize = 10000; |
| 72 | 72 |
| 73 // The maximum number of platform handles to attach for a single serialized |
| 74 // dispatcher. |
| 75 static const size_t kMaxSerializedDispatcherPlatformHandles = 2; |
| 76 |
| 73 // Forward-declare |Header| so that |View| can use it: | 77 // Forward-declare |Header| so that |View| can use it: |
| 74 private: | 78 private: |
| 75 struct Header; | 79 struct Header; |
| 76 public: | 80 public: |
| 77 // This represents a view of serialized message data in a raw buffer. | 81 // This represents a view of serialized message data in a raw buffer. |
| 78 class MOJO_SYSTEM_IMPL_EXPORT View { | 82 class MOJO_SYSTEM_IMPL_EXPORT View { |
| 79 public: | 83 public: |
| 80 // Constructs a view from the given buffer of the given size. (The size must | 84 // Constructs a view from the given buffer of the given size. (The size must |
| 81 // be as provided by |MessageInTransit::GetNextMessageSize()|.) The buffer | 85 // be as provided by |MessageInTransit::GetNextMessageSize()|.) The buffer |
| 82 // must remain alive/unmodified through the lifetime of this object. | 86 // must remain alive/unmodified through the lifetime of this object. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 struct HandleTableEntry { | 262 struct HandleTableEntry { |
| 259 int32_t type; // From |Dispatcher::Type| (|kTypeUnknown| for "invalid"). | 263 int32_t type; // From |Dispatcher::Type| (|kTypeUnknown| for "invalid"). |
| 260 uint32_t offset; // Relative to the start of the secondary buffer. | 264 uint32_t offset; // Relative to the start of the secondary buffer. |
| 261 uint32_t size; // (Not including any padding.) | 265 uint32_t size; // (Not including any padding.) |
| 262 uint32_t unused; | 266 uint32_t unused; |
| 263 }; | 267 }; |
| 264 | 268 |
| 265 // The maximum possible size of a valid secondary buffer. | 269 // The maximum possible size of a valid secondary buffer. |
| 266 static const size_t kMaxSecondaryBufferSize; | 270 static const size_t kMaxSecondaryBufferSize; |
| 267 | 271 |
| 272 // The maximum total number of platform handles that may be attached. |
| 273 static const size_t kMaxPlatformHandles; |
| 274 |
| 268 // Validates the secondary buffer. Returns null on success, or a | 275 // Validates the secondary buffer. Returns null on success, or a |
| 269 // human-readable error message (meant for logging/debugging) on error. | 276 // human-readable error message (meant for logging/debugging) on error. |
| 270 static const char* ValidateSecondaryBuffer(size_t num_handles, | 277 static const char* ValidateSecondaryBuffer(size_t num_handles, |
| 271 const void* secondary_buffer, | 278 const void* secondary_buffer, |
| 272 size_t secondary_buffer_size); | 279 size_t secondary_buffer_size); |
| 273 | 280 |
| 274 const Header* header() const { | 281 const Header* header() const { |
| 275 return static_cast<const Header*>(main_buffer_); | 282 return static_cast<const Header*>(main_buffer_); |
| 276 } | 283 } |
| 277 Header* header() { return static_cast<Header*>(main_buffer_); } | 284 Header* header() { return static_cast<Header*>(main_buffer_); } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 296 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandles|. | 303 // TODO(vtl): With C++11, change it to a vector of |ScopedPlatformHandles|. |
| 297 scoped_ptr<std::vector<embedder::PlatformHandle> > platform_handles_; | 304 scoped_ptr<std::vector<embedder::PlatformHandle> > platform_handles_; |
| 298 | 305 |
| 299 DISALLOW_COPY_AND_ASSIGN(MessageInTransit); | 306 DISALLOW_COPY_AND_ASSIGN(MessageInTransit); |
| 300 }; | 307 }; |
| 301 | 308 |
| 302 } // namespace system | 309 } // namespace system |
| 303 } // namespace mojo | 310 } // namespace mojo |
| 304 | 311 |
| 305 #endif // MOJO_SYSTEM_MESSAGE_IN_TRANSIT_H_ | 312 #endif // MOJO_SYSTEM_MESSAGE_IN_TRANSIT_H_ |
| OLD | NEW |