Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Side by Side Diff: ipc/ipc_sync_channel.cc

Issue 14383024: ipc: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698