| 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/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void RawChannel::WriteBuffer::GetPlatformHandlesToSend( | 73 void RawChannel::WriteBuffer::GetPlatformHandlesToSend( |
| 74 size_t* num_platform_handles, | 74 size_t* num_platform_handles, |
| 75 embedder::PlatformHandle** platform_handles, | 75 embedder::PlatformHandle** platform_handles, |
| 76 void** serialization_data) { | 76 void** serialization_data) { |
| 77 DCHECK(HavePlatformHandlesToSend()); | 77 DCHECK(HavePlatformHandlesToSend()); |
| 78 | 78 |
| 79 TransportData* transport_data = message_queue_.front()->transport_data(); | 79 MessageInTransit* message = message_queue_.front(); |
| 80 TransportData* transport_data = message->transport_data(); |
| 80 embedder::PlatformHandleVector* all_platform_handles = | 81 embedder::PlatformHandleVector* all_platform_handles = |
| 81 transport_data->platform_handles(); | 82 transport_data->platform_handles(); |
| 82 *num_platform_handles = | 83 *num_platform_handles = |
| 83 all_platform_handles->size() - platform_handles_offset_; | 84 all_platform_handles->size() - platform_handles_offset_; |
| 84 *platform_handles = &(*all_platform_handles)[platform_handles_offset_]; | 85 *platform_handles = &(*all_platform_handles)[platform_handles_offset_]; |
| 85 size_t serialization_data_offset = | 86 |
| 86 transport_data->platform_handle_table_offset(); | 87 if (serialized_platform_handle_size_ > 0) { |
| 87 DCHECK_GT(serialization_data_offset, 0u); | 88 size_t serialization_data_offset = |
| 88 serialization_data_offset += | 89 transport_data->platform_handle_table_offset(); |
| 89 platform_handles_offset_ * serialized_platform_handle_size_; | 90 DCHECK_GT(serialization_data_offset, 0u); |
| 90 *serialization_data = | 91 serialization_data_offset += |
| 91 static_cast<char*>(transport_data->buffer()) + serialization_data_offset; | 92 platform_handles_offset_ * serialized_platform_handle_size_; |
| 93 *serialization_data = static_cast<char*>(transport_data->buffer()) + |
| 94 serialization_data_offset; |
| 95 } else { |
| 96 *serialization_data = nullptr; |
| 97 } |
| 92 } | 98 } |
| 93 | 99 |
| 94 void RawChannel::WriteBuffer::GetBuffers(std::vector<Buffer>* buffers) const { | 100 void RawChannel::WriteBuffer::GetBuffers(std::vector<Buffer>* buffers) const { |
| 95 buffers->clear(); | 101 buffers->clear(); |
| 96 | 102 |
| 97 if (message_queue_.empty()) | 103 if (message_queue_.empty()) |
| 98 return; | 104 return; |
| 99 | 105 |
| 100 MessageInTransit* message = message_queue_.front(); | 106 MessageInTransit* message = message_queue_.front(); |
| 101 DCHECK_LT(data_offset_, message->total_size()); | 107 DCHECK_LT(data_offset_, message->total_size()); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 513 |
| 508 write_stopped_ = true; | 514 write_stopped_ = true; |
| 509 STLDeleteElements(&write_buffer_->message_queue_); | 515 STLDeleteElements(&write_buffer_->message_queue_); |
| 510 write_buffer_->platform_handles_offset_ = 0; | 516 write_buffer_->platform_handles_offset_ = 0; |
| 511 write_buffer_->data_offset_ = 0; | 517 write_buffer_->data_offset_ = 0; |
| 512 return false; | 518 return false; |
| 513 } | 519 } |
| 514 | 520 |
| 515 } // namespace system | 521 } // namespace system |
| 516 } // namespace mojo | 522 } // namespace mojo |
| OLD | NEW |