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 | |
9 #include <ostream> | 8 #include <ostream> |
| 9 #include <utility> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "mojo/edk/system/configuration.h" | 12 #include "mojo/edk/system/configuration.h" |
13 #include "mojo/edk/system/transport_data.h" | 13 #include "mojo/edk/system/transport_data.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace edk { | 16 namespace edk { |
17 | 17 |
18 MOJO_STATIC_CONST_MEMBER_DEFINITION const size_t | 18 MOJO_STATIC_CONST_MEMBER_DEFINITION const size_t |
19 MessageInTransit::kMessageAlignment; | 19 MessageInTransit::kMessageAlignment; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 DCHECK_EQ(*next_message_size % kMessageAlignment, 0u); | 126 DCHECK_EQ(*next_message_size % kMessageAlignment, 0u); |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 void MessageInTransit::SetDispatchers( | 130 void MessageInTransit::SetDispatchers( |
131 scoped_ptr<DispatcherVector> dispatchers) { | 131 scoped_ptr<DispatcherVector> dispatchers) { |
132 DCHECK(dispatchers); | 132 DCHECK(dispatchers); |
133 DCHECK(!dispatchers_); | 133 DCHECK(!dispatchers_); |
134 DCHECK(!transport_data_); | 134 DCHECK(!transport_data_); |
135 | 135 |
136 dispatchers_ = dispatchers.Pass(); | 136 dispatchers_ = std::move(dispatchers); |
137 } | 137 } |
138 | 138 |
139 void MessageInTransit::SetTransportData( | 139 void MessageInTransit::SetTransportData( |
140 scoped_ptr<TransportData> transport_data) { | 140 scoped_ptr<TransportData> transport_data) { |
141 DCHECK(transport_data); | 141 DCHECK(transport_data); |
142 DCHECK(!transport_data_); | 142 DCHECK(!transport_data_); |
143 DCHECK(!dispatchers_); | 143 DCHECK(!dispatchers_); |
144 | 144 |
145 transport_data_ = transport_data.Pass(); | 145 transport_data_ = std::move(transport_data); |
146 UpdateTotalSize(); | 146 UpdateTotalSize(); |
147 } | 147 } |
148 | 148 |
149 void MessageInTransit::SerializeAndCloseDispatchers() { | 149 void MessageInTransit::SerializeAndCloseDispatchers() { |
150 DCHECK(!transport_data_); | 150 DCHECK(!transport_data_); |
151 | 151 |
152 if (!dispatchers_ || !dispatchers_->size()) | 152 if (!dispatchers_ || !dispatchers_->size()) |
153 return; | 153 return; |
154 | 154 |
155 transport_data_.reset(new TransportData(dispatchers_.Pass())); | 155 transport_data_.reset(new TransportData(std::move(dispatchers_))); |
156 | 156 |
157 // Update the sizes in the message header. | 157 // Update the sizes in the message header. |
158 UpdateTotalSize(); | 158 UpdateTotalSize(); |
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. |
(...skipping 10 matching lines...) Expand all Loading... |
176 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); | 176 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); |
177 header()->total_size = static_cast<uint32_t>(main_buffer_size_); | 177 header()->total_size = static_cast<uint32_t>(main_buffer_size_); |
178 if (transport_data_) { | 178 if (transport_data_) { |
179 header()->total_size += | 179 header()->total_size += |
180 static_cast<uint32_t>(transport_data_->buffer_size()); | 180 static_cast<uint32_t>(transport_data_->buffer_size()); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 } // namespace edk | 184 } // namespace edk |
185 } // namespace mojo | 185 } // namespace mojo |
OLD | NEW |