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 #include <utility> | 10 #include <utility> |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 } else { | 326 } else { |
327 embedder::ScopedPlatformHandleVectorPtr platform_handles; | 327 embedder::ScopedPlatformHandleVectorPtr platform_handles; |
328 if (message_view.transport_data_buffer()) { | 328 if (message_view.transport_data_buffer()) { |
329 size_t num_platform_handles; | 329 size_t num_platform_handles; |
330 const void* platform_handle_table; | 330 const void* platform_handle_table; |
331 TransportData::GetPlatformHandleTable( | 331 TransportData::GetPlatformHandleTable( |
332 message_view.transport_data_buffer(), &num_platform_handles, | 332 message_view.transport_data_buffer(), &num_platform_handles, |
333 &platform_handle_table); | 333 &platform_handle_table); |
334 | 334 |
335 if (num_platform_handles > 0) { | 335 if (num_platform_handles > 0) { |
336 platform_handles = | 336 platform_handles = GetReadPlatformHandles(num_platform_handles, |
337 GetReadPlatformHandles(num_platform_handles, | 337 platform_handle_table); |
338 platform_handle_table).Pass(); | |
339 if (!platform_handles) { | 338 if (!platform_handles) { |
340 LOG(ERROR) << "Invalid number of platform handles received"; | 339 LOG(ERROR) << "Invalid number of platform handles received"; |
341 CallOnError(Delegate::ERROR_READ_BAD_MESSAGE); | 340 CallOnError(Delegate::ERROR_READ_BAD_MESSAGE); |
342 return; // |this| may have been destroyed in |CallOnError()|. | 341 return; // |this| may have been destroyed in |CallOnError()|. |
343 } | 342 } |
344 } | 343 } |
345 } | 344 } |
346 | 345 |
347 // TODO(vtl): In the case that we aren't expecting any platform handles, | 346 // TODO(vtl): In the case that we aren't expecting any platform handles, |
348 // for the POSIX implementation, we should confirm that none are stored. | 347 // for the POSIX implementation, we should confirm that none are stored. |
349 | 348 |
350 // Dispatch the message. | 349 // Dispatch the message. |
351 // Detect the case when |Shutdown()| is called; subsequent destruction | 350 // Detect the case when |Shutdown()| is called; subsequent destruction |
352 // is also permitted then. | 351 // is also permitted then. |
353 bool shutdown_called = false; | 352 bool shutdown_called = false; |
354 DCHECK(!set_on_shutdown_); | 353 DCHECK(!set_on_shutdown_); |
355 set_on_shutdown_ = &shutdown_called; | 354 set_on_shutdown_ = &shutdown_called; |
356 DCHECK(delegate_); | 355 DCHECK(delegate_); |
357 delegate_->OnReadMessage(message_view, platform_handles.Pass()); | 356 delegate_->OnReadMessage(message_view, std::move(platform_handles)); |
358 if (shutdown_called) | 357 if (shutdown_called) |
359 return; | 358 return; |
360 set_on_shutdown_ = nullptr; | 359 set_on_shutdown_ = nullptr; |
361 } | 360 } |
362 | 361 |
363 did_dispatch_message = true; | 362 did_dispatch_message = true; |
364 | 363 |
365 // Update our state. | 364 // Update our state. |
366 read_buffer_start += message_size; | 365 read_buffer_start += message_size; |
367 remaining_bytes -= message_size; | 366 remaining_bytes -= message_size; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 504 |
506 write_stopped_ = true; | 505 write_stopped_ = true; |
507 write_buffer_->message_queue_.Clear(); | 506 write_buffer_->message_queue_.Clear(); |
508 write_buffer_->platform_handles_offset_ = 0; | 507 write_buffer_->platform_handles_offset_ = 0; |
509 write_buffer_->data_offset_ = 0; | 508 write_buffer_->data_offset_ = 0; |
510 return false; | 509 return false; |
511 } | 510 } |
512 | 511 |
513 } // namespace system | 512 } // namespace system |
514 } // namespace mojo | 513 } // namespace mojo |
OLD | NEW |