OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/thread_local.h" | 9 #include "base/thread_local.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 sync_msg_queue->set_top_send_done_watcher(&send_done_watcher); | 461 sync_msg_queue->set_top_send_done_watcher(&send_done_watcher); |
462 | 462 |
463 send_done_watcher.StartWatching(sync_context()->GetSendDoneEvent(), this); | 463 send_done_watcher.StartWatching(sync_context()->GetSendDoneEvent(), this); |
464 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 464 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
465 | 465 |
466 MessageLoop::current()->SetNestableTasksAllowed(true); | 466 MessageLoop::current()->SetNestableTasksAllowed(true); |
467 MessageLoop::current()->Run(); | 467 MessageLoop::current()->Run(); |
468 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 468 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
469 | 469 |
470 sync_msg_queue->set_top_send_done_watcher(old_send_done_event_watcher); | 470 sync_msg_queue->set_top_send_done_watcher(old_send_done_event_watcher); |
471 if (old_send_done_event_watcher) { | 471 if (old_send_done_event_watcher && old_event) { |
472 old_send_done_event_watcher->StartWatching(old_event, old_delegate); | 472 old_send_done_event_watcher->StartWatching(old_event, old_delegate); |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) { | 476 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) { |
477 WaitableEvent* dispatch_event = sync_context()->GetDispatchEvent(); | 477 WaitableEvent* dispatch_event = sync_context()->GetDispatchEvent(); |
478 if (event == dispatch_event) { | 478 if (event == dispatch_event) { |
479 // The call to DispatchMessages might delete this object, so reregister | 479 // The call to DispatchMessages might delete this object, so reregister |
480 // the object watcher first. | 480 // the object watcher first. |
481 dispatch_event->Reset(); | 481 dispatch_event->Reset(); |
482 dispatch_watcher_.StartWatching(dispatch_event, this); | 482 dispatch_watcher_.StartWatching(dispatch_event, this); |
483 sync_context()->DispatchMessages(); | 483 sync_context()->DispatchMessages(); |
484 } else { | 484 } else { |
485 // We got the reply, timed out or the process shutdown. | 485 // We got the reply, timed out or the process shutdown. |
486 DCHECK(event == sync_context()->GetSendDoneEvent()); | 486 DCHECK(event == sync_context()->GetSendDoneEvent()); |
487 MessageLoop::current()->Quit(); | 487 MessageLoop::current()->Quit(); |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 } // namespace IPC | 491 } // namespace IPC |
OLD | NEW |