OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/transport_data.h" | 5 #include "mojo/edk/system/transport_data.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
| 9 #include <utility> |
| 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "mojo/edk/system/channel.h" | 12 #include "mojo/edk/system/channel.h" |
11 #include "mojo/edk/system/configuration.h" | 13 #include "mojo/edk/system/configuration.h" |
12 #include "mojo/edk/system/message_in_transit.h" | 14 #include "mojo/edk/system/message_in_transit.h" |
13 | 15 |
14 namespace mojo { | 16 namespace mojo { |
15 namespace system { | 17 namespace system { |
16 | 18 |
17 // The maximum amount of space needed per platform handle. | 19 // The maximum amount of space needed per platform handle. |
18 // (|{Channel,RawChannel}::GetSerializedPlatformHandleSize()| should always | 20 // (|{Channel,RawChannel}::GetSerializedPlatformHandleSize()| should always |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // There's no aligned realloc, so it's no good way to release unused space (if | 189 // There's no aligned realloc, so it's no good way to release unused space (if |
188 // we overshot our estimated space requirements). | 190 // we overshot our estimated space requirements). |
189 buffer_size_ = current_offset; | 191 buffer_size_ = current_offset; |
190 | 192 |
191 // |dispatchers_| will be destroyed as it goes out of scope. | 193 // |dispatchers_| will be destroyed as it goes out of scope. |
192 } | 194 } |
193 | 195 |
194 TransportData::TransportData( | 196 TransportData::TransportData( |
195 embedder::ScopedPlatformHandleVectorPtr platform_handles, | 197 embedder::ScopedPlatformHandleVectorPtr platform_handles, |
196 size_t serialized_platform_handle_size) | 198 size_t serialized_platform_handle_size) |
197 : buffer_size_(), platform_handles_(platform_handles.Pass()) { | 199 : buffer_size_(), platform_handles_(std::move(platform_handles)) { |
198 buffer_size_ = MessageInTransit::RoundUpMessageAlignment( | 200 buffer_size_ = MessageInTransit::RoundUpMessageAlignment( |
199 sizeof(Header) + | 201 sizeof(Header) + |
200 platform_handles_->size() * serialized_platform_handle_size); | 202 platform_handles_->size() * serialized_platform_handle_size); |
201 buffer_.reset(static_cast<char*>( | 203 buffer_.reset(static_cast<char*>( |
202 base::AlignedAlloc(buffer_size_, MessageInTransit::kMessageAlignment))); | 204 base::AlignedAlloc(buffer_size_, MessageInTransit::kMessageAlignment))); |
203 memset(buffer_.get(), 0, buffer_size_); | 205 memset(buffer_.get(), 0, buffer_size_); |
204 | 206 |
205 Header* header = reinterpret_cast<Header*>(buffer_.get()); | 207 Header* header = reinterpret_cast<Header*>(buffer_.get()); |
206 header->platform_handle_table_offset = static_cast<uint32_t>(sizeof(Header)); | 208 header->platform_handle_table_offset = static_cast<uint32_t>(sizeof(Header)); |
207 header->num_platform_handles = | 209 header->num_platform_handles = |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 const void* source = static_cast<const char*>(buffer) + offset; | 336 const void* source = static_cast<const char*>(buffer) + offset; |
335 (*dispatchers)[i] = Dispatcher::TransportDataAccess::Deserialize( | 337 (*dispatchers)[i] = Dispatcher::TransportDataAccess::Deserialize( |
336 channel, handle_table[i].type, source, size, platform_handles.get()); | 338 channel, handle_table[i].type, source, size, platform_handles.get()); |
337 } | 339 } |
338 | 340 |
339 return dispatchers; | 341 return dispatchers; |
340 } | 342 } |
341 | 343 |
342 } // namespace system | 344 } // namespace system |
343 } // namespace mojo | 345 } // namespace mojo |
OLD | NEW |