| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_pipe_dispatcher.h" | 5 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 #endif | 429 #endif |
| 430 } | 430 } |
| 431 | 431 |
| 432 void MessagePipeDispatcher::CancelAllAwakablesNoLock() { | 432 void MessagePipeDispatcher::CancelAllAwakablesNoLock() { |
| 433 lock().AssertAcquired(); | 433 lock().AssertAcquired(); |
| 434 awakable_list_.CancelAll(); | 434 awakable_list_.CancelAll(); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void MessagePipeDispatcher::CloseImplNoLock() { | 437 void MessagePipeDispatcher::CloseImplNoLock() { |
| 438 lock().AssertAcquired(); | 438 lock().AssertAcquired(); |
| 439 // This early circuit fixes leak in unit tests. There's nothing to do in the |
| 440 // posted task. |
| 441 if (!transferable_ && non_transferable_state_ == CLOSED) |
| 442 return; |
| 443 |
| 439 // We take a manual refcount because at shutdown, the task below might not get | 444 // We take a manual refcount because at shutdown, the task below might not get |
| 440 // a chance to execute. If that happens, the RawChannel's will still call our | 445 // a chance to execute. If that happens, the RawChannel will still call our |
| 441 // OnError method because it always runs (since it watches thread | 446 // OnError method because it always runs (since it watches thread |
| 442 // destruction). So to avoid UAF, manually add a reference and only release it | 447 // destruction). So to avoid UAF, manually add a reference and only release it |
| 443 // if the task runs. | 448 // if the task runs. |
| 444 AddRef(); | 449 AddRef(); |
| 445 internal::g_io_thread_task_runner->PostTask( | 450 internal::g_io_thread_task_runner->PostTask( |
| 446 FROM_HERE, base::Bind(&MessagePipeDispatcher::CloseOnIO, this)); | 451 FROM_HERE, base::Bind(&MessagePipeDispatcher::CloseOnIO, this)); |
| 447 } | 452 } |
| 448 | 453 |
| 449 void MessagePipeDispatcher::SerializeInternal() { | 454 void MessagePipeDispatcher::SerializeInternal() { |
| 450 serialized_ = true; | 455 serialized_ = true; |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 // PostTask since the broker can call us back synchronously. | 1002 // PostTask since the broker can call us back synchronously. |
| 998 internal::g_io_thread_task_runner->PostTask( | 1003 internal::g_io_thread_task_runner->PostTask( |
| 999 FROM_HERE, | 1004 FROM_HERE, |
| 1000 base::Bind(&Broker::ConnectMessagePipe, | 1005 base::Bind(&Broker::ConnectMessagePipe, |
| 1001 base::Unretained(internal::g_broker), pipe_id_, | 1006 base::Unretained(internal::g_broker), pipe_id_, |
| 1002 base::Unretained(this))); | 1007 base::Unretained(this))); |
| 1003 } | 1008 } |
| 1004 | 1009 |
| 1005 } // namespace edk | 1010 } // namespace edk |
| 1006 } // namespace mojo | 1011 } // namespace mojo |
| OLD | NEW |