| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ipc/ipc_sync_channel.h" | 5 #include "ipc/ipc_sync_channel.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 SyncChannel::SyncChannel( | 371 SyncChannel::SyncChannel( |
| 372 const IPC::ChannelHandle& channel_handle, | 372 const IPC::ChannelHandle& channel_handle, |
| 373 Channel::Mode mode, | 373 Channel::Mode mode, |
| 374 Channel::Listener* listener, | 374 Channel::Listener* listener, |
| 375 base::MessageLoopProxy* ipc_message_loop, | 375 base::MessageLoopProxy* ipc_message_loop, |
| 376 bool create_pipe_now, | 376 bool create_pipe_now, |
| 377 WaitableEvent* shutdown_event) | 377 WaitableEvent* shutdown_event) |
| 378 : ChannelProxy( | 378 : ChannelProxy( |
| 379 channel_handle, mode, ipc_message_loop, | 379 channel_handle, mode, ipc_message_loop, |
| 380 false /* needs_override_peer_pid */, | |
| 381 new SyncContext(listener, ipc_message_loop, shutdown_event), | 380 new SyncContext(listener, ipc_message_loop, shutdown_event), |
| 382 create_pipe_now), | 381 create_pipe_now), |
| 383 sync_messages_with_no_timeout_allowed_(true) { | 382 sync_messages_with_no_timeout_allowed_(true) { |
| 384 // Ideally we only want to watch this object when running a nested message | 383 // Ideally we only want to watch this object when running a nested message |
| 385 // loop. However, we don't know when it exits if there's another nested | 384 // loop. However, we don't know when it exits if there's another nested |
| 386 // message loop running under it or not, so we wouldn't know whether to | 385 // message loop running under it or not, so we wouldn't know whether to |
| 387 // stop or keep watching. So we always watch it, and create the event as | 386 // stop or keep watching. So we always watch it, and create the event as |
| 388 // manual reset since the object watcher might otherwise reset the event | 387 // manual reset since the object watcher might otherwise reset the event |
| 389 // when we're doing a WaitMany. | 388 // when we're doing a WaitMany. |
| 390 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); | 389 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) { | 504 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) { |
| 506 DCHECK(event == sync_context()->GetDispatchEvent()); | 505 DCHECK(event == sync_context()->GetDispatchEvent()); |
| 507 // The call to DispatchMessages might delete this object, so reregister | 506 // The call to DispatchMessages might delete this object, so reregister |
| 508 // the object watcher first. | 507 // the object watcher first. |
| 509 event->Reset(); | 508 event->Reset(); |
| 510 dispatch_watcher_.StartWatching(event, this); | 509 dispatch_watcher_.StartWatching(event, this); |
| 511 sync_context()->DispatchMessages(); | 510 sync_context()->DispatchMessages(); |
| 512 } | 511 } |
| 513 | 512 |
| 514 } // namespace IPC | 513 } // namespace IPC |
| OLD | NEW |