| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 | 406 |
| 407 SyncChannel::SyncChannel( | 407 SyncChannel::SyncChannel( |
| 408 const IPC::ChannelHandle& channel_handle, | 408 const IPC::ChannelHandle& channel_handle, |
| 409 Channel::Mode mode, | 409 Channel::Mode mode, |
| 410 Listener* listener, | 410 Listener* listener, |
| 411 base::SingleThreadTaskRunner* ipc_task_runner, | 411 base::SingleThreadTaskRunner* ipc_task_runner, |
| 412 bool create_pipe_now, | 412 bool create_pipe_now, |
| 413 WaitableEvent* shutdown_event) | 413 WaitableEvent* shutdown_event) |
| 414 : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { | 414 : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { |
| 415 // The current (listener) thread must be distinct from the IPC thread, or else |
| 416 // sending synchronous messages will deadlock. |
| 417 DCHECK_NE(ipc_task_runner, base::ThreadTaskRunnerHandle::Get()); |
| 415 ChannelProxy::Init(channel_handle, mode, create_pipe_now); | 418 ChannelProxy::Init(channel_handle, mode, create_pipe_now); |
| 416 StartWatching(); | 419 StartWatching(); |
| 417 } | 420 } |
| 418 | 421 |
| 419 SyncChannel::SyncChannel( | 422 SyncChannel::SyncChannel( |
| 420 Listener* listener, | 423 Listener* listener, |
| 421 base::SingleThreadTaskRunner* ipc_task_runner, | 424 base::SingleThreadTaskRunner* ipc_task_runner, |
| 422 WaitableEvent* shutdown_event) | 425 WaitableEvent* shutdown_event) |
| 423 : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { | 426 : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { |
| 427 // The current (listener) thread must be distinct from the IPC thread, or else |
| 428 // sending synchronous messages will deadlock. |
| 429 DCHECK_NE(ipc_task_runner, base::ThreadTaskRunnerHandle::Get()); |
| 424 StartWatching(); | 430 StartWatching(); |
| 425 } | 431 } |
| 426 | 432 |
| 427 SyncChannel::~SyncChannel() { | 433 SyncChannel::~SyncChannel() { |
| 428 } | 434 } |
| 429 | 435 |
| 430 void SyncChannel::SetRestrictDispatchChannelGroup(int group) { | 436 void SyncChannel::SetRestrictDispatchChannelGroup(int group) { |
| 431 sync_context()->set_restrict_dispatch_group(group); | 437 sync_context()->set_restrict_dispatch_group(group); |
| 432 } | 438 } |
| 433 | 439 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 // manual reset since the object watcher might otherwise reset the event | 556 // manual reset since the object watcher might otherwise reset the event |
| 551 // when we're doing a WaitMany. | 557 // when we're doing a WaitMany. |
| 552 dispatch_watcher_callback_ = | 558 dispatch_watcher_callback_ = |
| 553 base::Bind(&SyncChannel::OnWaitableEventSignaled, | 559 base::Bind(&SyncChannel::OnWaitableEventSignaled, |
| 554 base::Unretained(this)); | 560 base::Unretained(this)); |
| 555 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), | 561 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), |
| 556 dispatch_watcher_callback_); | 562 dispatch_watcher_callback_); |
| 557 } | 563 } |
| 558 | 564 |
| 559 } // namespace IPC | 565 } // namespace IPC |
| OLD | NEW |