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 #include "mojo/edk/system/message_in_transit.h" | 5 #include "mojo/edk/system/message_in_transit.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Update the sizes in the message header. | 159 // Update the sizes in the message header. |
160 UpdateTotalSize(); | 160 UpdateTotalSize(); |
161 } | 161 } |
162 | 162 |
163 void MessageInTransit::ConstructorHelper(Type type, | 163 void MessageInTransit::ConstructorHelper(Type type, |
164 uint32_t num_bytes) { | 164 uint32_t num_bytes) { |
165 DCHECK_LE(num_bytes, GetConfiguration().max_message_num_bytes); | 165 DCHECK_LE(num_bytes, GetConfiguration().max_message_num_bytes); |
166 | 166 |
167 // |total_size| is updated below, from the other values. | 167 // |total_size| is updated below, from the other values. |
168 header()->type = type; | 168 header()->type = type; |
| 169 header()->unusedforalignment = 0; |
169 header()->num_bytes = num_bytes; | 170 header()->num_bytes = num_bytes; |
170 header()->unused = 0; | 171 header()->unused = 0; |
171 header()->route_id = 0; | 172 header()->route_id = 0; |
172 // Note: If dispatchers are subsequently attached, then |total_size| will have | 173 // Note: If dispatchers are subsequently attached, then |total_size| will have |
173 // to be adjusted. | 174 // to be adjusted. |
174 UpdateTotalSize(); | 175 UpdateTotalSize(); |
175 } | 176 } |
176 | 177 |
177 void MessageInTransit::UpdateTotalSize() { | 178 void MessageInTransit::UpdateTotalSize() { |
178 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); | 179 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); |
179 header()->total_size = static_cast<uint32_t>(main_buffer_size_); | 180 header()->total_size = static_cast<uint32_t>(main_buffer_size_); |
180 if (transport_data_) { | 181 if (transport_data_) { |
181 header()->total_size += | 182 header()->total_size += |
182 static_cast<uint32_t>(transport_data_->buffer_size()); | 183 static_cast<uint32_t>(transport_data_->buffer_size()); |
183 } | 184 } |
184 } | 185 } |
185 | 186 |
186 } // namespace edk | 187 } // namespace edk |
187 } // namespace mojo | 188 } // namespace mojo |
OLD | NEW |