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