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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 // API parallel to that for |MessageInTransit| itself (mostly getters for | 100 // API parallel to that for |MessageInTransit| itself (mostly getters for |
101 // header data). | 101 // header data). |
102 const void* main_buffer() const { return buffer_; } | 102 const void* main_buffer() const { return buffer_; } |
103 size_t main_buffer_size() const { | 103 size_t main_buffer_size() const { |
104 return RoundUpMessageAlignment(sizeof(Header) + header()->num_bytes); | 104 return RoundUpMessageAlignment(sizeof(Header) + header()->num_bytes); |
105 } | 105 } |
106 const void* transport_data_buffer() const { | 106 const void* transport_data_buffer() const { |
107 return (total_size() > main_buffer_size()) | 107 return (total_size() > main_buffer_size()) |
108 ? static_cast<const char*>(buffer_) + main_buffer_size() | 108 ? static_cast<const char*>(buffer_) + main_buffer_size() |
109 : NULL; | 109 : nullptr; |
110 } | 110 } |
111 size_t transport_data_buffer_size() const { | 111 size_t transport_data_buffer_size() const { |
112 return total_size() - main_buffer_size(); | 112 return total_size() - main_buffer_size(); |
113 } | 113 } |
114 size_t total_size() const { return header()->total_size; } | 114 size_t total_size() const { return header()->total_size; } |
115 uint32_t num_bytes() const { return header()->num_bytes; } | 115 uint32_t num_bytes() const { return header()->num_bytes; } |
116 const void* bytes() const { | 116 const void* bytes() const { |
117 return static_cast<const char*>(buffer_) + sizeof(Header); | 117 return static_cast<const char*>(buffer_) + sizeof(Header); |
118 } | 118 } |
119 Type type() const { return header()->type; } | 119 Type type() const { return header()->type; } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // some reason.) | 258 // some reason.) |
259 scoped_ptr<DispatcherVector> dispatchers_; | 259 scoped_ptr<DispatcherVector> dispatchers_; |
260 | 260 |
261 DISALLOW_COPY_AND_ASSIGN(MessageInTransit); | 261 DISALLOW_COPY_AND_ASSIGN(MessageInTransit); |
262 }; | 262 }; |
263 | 263 |
264 } // namespace system | 264 } // namespace system |
265 } // namespace mojo | 265 } // namespace mojo |
266 | 266 |
267 #endif // MOJO_SYSTEM_MESSAGE_IN_TRANSIT_H_ | 267 #endif // MOJO_SYSTEM_MESSAGE_IN_TRANSIT_H_ |
OLD | NEW |