| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 388 } |
| 389 | 389 |
| 390 void SyncChannel::SyncContext::OnWaitableEventSignaled(WaitableEvent* event) { | 390 void SyncChannel::SyncContext::OnWaitableEventSignaled(WaitableEvent* event) { |
| 391 if (event == shutdown_event_) { | 391 if (event == shutdown_event_) { |
| 392 // Process shut down before we can get a reply to a synchronous message. | 392 // Process shut down before we can get a reply to a synchronous message. |
| 393 // Cancel pending Send calls, which will end up setting the send done event. | 393 // Cancel pending Send calls, which will end up setting the send done event. |
| 394 CancelPendingSends(); | 394 CancelPendingSends(); |
| 395 } else { | 395 } else { |
| 396 // We got the reply, timed out or the process shutdown. | 396 // We got the reply, timed out or the process shutdown. |
| 397 DCHECK_EQ(GetSendDoneEvent(), event); | 397 DCHECK_EQ(GetSendDoneEvent(), event); |
| 398 MessageLoop::current()->QuitNow(); | 398 base::MessageLoop::current()->QuitNow(); |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 | 401 |
| 402 base::WaitableEventWatcher::EventCallback | 402 base::WaitableEventWatcher::EventCallback |
| 403 SyncChannel::SyncContext::MakeWaitableEventCallback() { | 403 SyncChannel::SyncContext::MakeWaitableEventCallback() { |
| 404 return base::Bind(&SyncChannel::SyncContext::OnWaitableEventSignaled, this); | 404 return base::Bind(&SyncChannel::SyncContext::OnWaitableEventSignaled, this); |
| 405 } | 405 } |
| 406 | 406 |
| 407 SyncChannel::SyncChannel( | 407 SyncChannel::SyncChannel( |
| 408 const IPC::ChannelHandle& channel_handle, | 408 const IPC::ChannelHandle& channel_handle, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 old_event = old_send_done_event_watcher->GetWatchedEvent(); | 535 old_event = old_send_done_event_watcher->GetWatchedEvent(); |
| 536 old_send_done_event_watcher->StopWatching(); | 536 old_send_done_event_watcher->StopWatching(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 sync_msg_queue->set_top_send_done_watcher(&send_done_watcher); | 539 sync_msg_queue->set_top_send_done_watcher(&send_done_watcher); |
| 540 | 540 |
| 541 send_done_watcher.StartWatching(context->GetSendDoneEvent(), | 541 send_done_watcher.StartWatching(context->GetSendDoneEvent(), |
| 542 context->MakeWaitableEventCallback()); | 542 context->MakeWaitableEventCallback()); |
| 543 | 543 |
| 544 { | 544 { |
| 545 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 545 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 546 MessageLoop::current()->Run(); | 546 base::MessageLoop::current()); |
| 547 base::MessageLoop::current()->Run(); |
| 547 } | 548 } |
| 548 | 549 |
| 549 sync_msg_queue->set_top_send_done_watcher(old_send_done_event_watcher); | 550 sync_msg_queue->set_top_send_done_watcher(old_send_done_event_watcher); |
| 550 if (old_send_done_event_watcher && old_event) { | 551 if (old_send_done_event_watcher && old_event) { |
| 551 old_send_done_event_watcher->StartWatching(old_event, old_callback); | 552 old_send_done_event_watcher->StartWatching(old_event, old_callback); |
| 552 } | 553 } |
| 553 } | 554 } |
| 554 | 555 |
| 555 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) { | 556 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) { |
| 556 DCHECK(event == sync_context()->GetDispatchEvent()); | 557 DCHECK(event == sync_context()->GetDispatchEvent()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 569 // manual reset since the object watcher might otherwise reset the event | 570 // manual reset since the object watcher might otherwise reset the event |
| 570 // when we're doing a WaitMany. | 571 // when we're doing a WaitMany. |
| 571 dispatch_watcher_callback_ = | 572 dispatch_watcher_callback_ = |
| 572 base::Bind(&SyncChannel::OnWaitableEventSignaled, | 573 base::Bind(&SyncChannel::OnWaitableEventSignaled, |
| 573 base::Unretained(this)); | 574 base::Unretained(this)); |
| 574 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), | 575 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), |
| 575 dispatch_watcher_callback_); | 576 dispatch_watcher_callback_); |
| 576 } | 577 } |
| 577 | 578 |
| 578 } // namespace IPC | 579 } // namespace IPC |
| OLD | NEW |