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 <utility> | 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/dispatcher.h" |
13 #include "mojo/edk/system/transport_data.h" | 14 #include "mojo/edk/system/transport_data.h" |
14 | 15 |
15 using mojo::platform::AlignedAlloc; | 16 using mojo::platform::AlignedAlloc; |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 namespace system { | 19 namespace system { |
19 | 20 |
20 const size_t MessageInTransit::kMessageAlignment; | 21 const size_t MessageInTransit::kMessageAlignment; |
21 | 22 |
22 struct MessageInTransit::PrivateStructForCompileAsserts { | 23 struct MessageInTransit::PrivateStructForCompileAsserts { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 149 |
149 handles_ = std::move(handles); | 150 handles_ = std::move(handles); |
150 #ifndef NDEBUG | 151 #ifndef NDEBUG |
151 for (size_t i = 0; i < handles_->size(); i++) { | 152 for (size_t i = 0; i < handles_->size(); i++) { |
152 if (handles_->at(i)) | 153 if (handles_->at(i)) |
153 handles_->at(i).dispatcher->AssertHasOneRef(); | 154 handles_->at(i).dispatcher->AssertHasOneRef(); |
154 } | 155 } |
155 #endif | 156 #endif |
156 } | 157 } |
157 | 158 |
158 void MessageInTransit::SetDispatchers( | |
159 std::unique_ptr<DispatcherVector> dispatchers) { | |
160 DCHECK(dispatchers); | |
161 | |
162 std::unique_ptr<HandleVector> handles(new HandleVector()); | |
163 handles->reserve(dispatchers->size()); | |
164 for (size_t i = 0; i < dispatchers->size(); i++) { | |
165 handles->push_back( | |
166 Handle(std::move(dispatchers->at(i)), MOJO_HANDLE_RIGHT_NONE)); | |
167 } | |
168 SetHandles(std::move(handles)); | |
169 } | |
170 | |
171 void MessageInTransit::SetTransportData( | 159 void MessageInTransit::SetTransportData( |
172 std::unique_ptr<TransportData> transport_data) { | 160 std::unique_ptr<TransportData> transport_data) { |
173 DCHECK(transport_data); | 161 DCHECK(transport_data); |
174 DCHECK(!transport_data_); | 162 DCHECK(!transport_data_); |
175 DCHECK(!handles_); | 163 DCHECK(!handles_); |
176 | 164 |
177 transport_data_ = std::move(transport_data); | 165 transport_data_ = std::move(transport_data); |
178 UpdateTotalSize(); | 166 UpdateTotalSize(); |
179 } | 167 } |
180 | 168 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); | 200 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); |
213 header()->total_size = static_cast<uint32_t>(main_buffer_size_); | 201 header()->total_size = static_cast<uint32_t>(main_buffer_size_); |
214 if (transport_data_) { | 202 if (transport_data_) { |
215 header()->total_size += | 203 header()->total_size += |
216 static_cast<uint32_t>(transport_data_->buffer_size()); | 204 static_cast<uint32_t>(transport_data_->buffer_size()); |
217 } | 205 } |
218 } | 206 } |
219 | 207 |
220 } // namespace system | 208 } // namespace system |
221 } // namespace mojo | 209 } // namespace mojo |
OLD | NEW |