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/dispatcher.h" | 5 #include "mojo/edk/system/dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/edk/system/configuration.h" | 8 #include "mojo/edk/system/configuration.h" |
9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" | 9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 is_closed_ = true; | 446 is_closed_ = true; |
447 CancelAllAwakablesNoLock(); | 447 CancelAllAwakablesNoLock(); |
448 return CreateEquivalentDispatcherAndCloseImplNoLock(); | 448 return CreateEquivalentDispatcherAndCloseImplNoLock(); |
449 } | 449 } |
450 | 450 |
451 void Dispatcher::StartSerialize(size_t* max_size, | 451 void Dispatcher::StartSerialize(size_t* max_size, |
452 size_t* max_platform_handles) { | 452 size_t* max_platform_handles) { |
453 DCHECK(max_size); | 453 DCHECK(max_size); |
454 DCHECK(max_platform_handles); | 454 DCHECK(max_platform_handles); |
455 DCHECK(!is_closed_); | 455 DCHECK(!is_closed_); |
| 456 base::AutoLock locker(lock_); |
456 StartSerializeImplNoLock(max_size, max_platform_handles); | 457 StartSerializeImplNoLock(max_size, max_platform_handles); |
457 } | 458 } |
458 | 459 |
459 bool Dispatcher::EndSerializeAndClose(void* destination, | 460 bool Dispatcher::EndSerializeAndClose(void* destination, |
460 size_t* actual_size, | 461 size_t* actual_size, |
461 PlatformHandleVector* platform_handles) { | 462 PlatformHandleVector* platform_handles) { |
462 DCHECK(actual_size); | 463 DCHECK(actual_size); |
463 DCHECK(!is_closed_); | 464 DCHECK(!is_closed_); |
464 | 465 |
465 // Like other |...Close()| methods, we mark ourselves as closed before calling | 466 // Like other |...Close()| methods, we mark ourselves as closed before calling |
466 // the impl. But there's no need to cancel waiters: we shouldn't have any (and | 467 // the impl. But there's no need to cancel waiters: we shouldn't have any (and |
467 // shouldn't be in |Core|'s handle table. | 468 // shouldn't be in |Core|'s handle table. |
468 is_closed_ = true; | 469 is_closed_ = true; |
469 | 470 |
470 #if !defined(NDEBUG) | |
471 // See the comment above |EndSerializeAndCloseImplNoLock()|. In brief: Locking | |
472 // isn't actually needed, but we need to satisfy assertions (which we don't | |
473 // want to remove or weaken). | |
474 base::AutoLock locker(lock_); | 471 base::AutoLock locker(lock_); |
475 #endif | |
476 | |
477 return EndSerializeAndCloseImplNoLock(destination, actual_size, | 472 return EndSerializeAndCloseImplNoLock(destination, actual_size, |
478 platform_handles); | 473 platform_handles); |
479 } | 474 } |
480 | 475 |
481 // DispatcherTransport --------------------------------------------------------- | 476 // DispatcherTransport --------------------------------------------------------- |
482 | 477 |
483 void DispatcherTransport::End() { | 478 void DispatcherTransport::End() { |
484 DCHECK(dispatcher_); | 479 DCHECK(dispatcher_); |
485 dispatcher_->lock_.Release(); | 480 dispatcher_->lock_.Release(); |
486 | 481 |
487 dispatcher_->TransportEnded(); | 482 dispatcher_->TransportEnded(); |
488 | 483 |
489 dispatcher_ = nullptr; | 484 dispatcher_ = nullptr; |
490 } | 485 } |
491 | 486 |
492 } // namespace edk | 487 } // namespace edk |
493 } // namespace mojo | 488 } // namespace mojo |
OLD | NEW |