| 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/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // a local global stack of send done watchers to ensure that nested sync | 216 // a local global stack of send done watchers to ensure that nested sync |
| 217 // message loops complete correctly. | 217 // message loops complete correctly. |
| 218 base::WaitableEventWatcher* top_send_done_watcher_; | 218 base::WaitableEventWatcher* top_send_done_watcher_; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 base::LazyInstance<base::ThreadLocalPointer<SyncChannel::ReceivedSyncMsgQueue> > | 221 base::LazyInstance<base::ThreadLocalPointer<SyncChannel::ReceivedSyncMsgQueue> > |
| 222 SyncChannel::ReceivedSyncMsgQueue::lazy_tls_ptr_ = | 222 SyncChannel::ReceivedSyncMsgQueue::lazy_tls_ptr_ = |
| 223 LAZY_INSTANCE_INITIALIZER; | 223 LAZY_INSTANCE_INITIALIZER; |
| 224 | 224 |
| 225 SyncChannel::SyncContext::SyncContext( | 225 SyncChannel::SyncContext::SyncContext( |
| 226 Channel::Listener* listener, | 226 Listener* listener, |
| 227 base::MessageLoopProxy* ipc_thread, | 227 base::MessageLoopProxy* ipc_thread, |
| 228 WaitableEvent* shutdown_event) | 228 WaitableEvent* shutdown_event) |
| 229 : ChannelProxy::Context(listener, ipc_thread), | 229 : ChannelProxy::Context(listener, ipc_thread), |
| 230 received_sync_msgs_(ReceivedSyncMsgQueue::AddContext()), | 230 received_sync_msgs_(ReceivedSyncMsgQueue::AddContext()), |
| 231 shutdown_event_(shutdown_event), | 231 shutdown_event_(shutdown_event), |
| 232 restrict_dispatch_group_(kRestrictDispatchGroup_None) { | 232 restrict_dispatch_group_(kRestrictDispatchGroup_None) { |
| 233 } | 233 } |
| 234 | 234 |
| 235 SyncChannel::SyncContext::~SyncContext() { | 235 SyncChannel::SyncContext::~SyncContext() { |
| 236 while (!deserializers_.empty()) | 236 while (!deserializers_.empty()) |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 // We got the reply, timed out or the process shutdown. | 380 // We got the reply, timed out or the process shutdown. |
| 381 DCHECK_EQ(GetSendDoneEvent(), event); | 381 DCHECK_EQ(GetSendDoneEvent(), event); |
| 382 MessageLoop::current()->QuitNow(); | 382 MessageLoop::current()->QuitNow(); |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 | 385 |
| 386 | 386 |
| 387 SyncChannel::SyncChannel( | 387 SyncChannel::SyncChannel( |
| 388 const IPC::ChannelHandle& channel_handle, | 388 const IPC::ChannelHandle& channel_handle, |
| 389 Channel::Mode mode, | 389 Channel::Mode mode, |
| 390 Channel::Listener* listener, | 390 Listener* listener, |
| 391 base::MessageLoopProxy* ipc_message_loop, | 391 base::MessageLoopProxy* ipc_message_loop, |
| 392 bool create_pipe_now, | 392 bool create_pipe_now, |
| 393 WaitableEvent* shutdown_event) | 393 WaitableEvent* shutdown_event) |
| 394 : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)), | 394 : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)), |
| 395 sync_messages_with_no_timeout_allowed_(true) { | 395 sync_messages_with_no_timeout_allowed_(true) { |
| 396 ChannelProxy::Init(channel_handle, mode, create_pipe_now); | 396 ChannelProxy::Init(channel_handle, mode, create_pipe_now); |
| 397 StartWatching(); | 397 StartWatching(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 SyncChannel::SyncChannel( | 400 SyncChannel::SyncChannel( |
| 401 Channel::Listener* listener, | 401 Listener* listener, |
| 402 base::MessageLoopProxy* ipc_message_loop, | 402 base::MessageLoopProxy* ipc_message_loop, |
| 403 WaitableEvent* shutdown_event) | 403 WaitableEvent* shutdown_event) |
| 404 : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)), | 404 : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)), |
| 405 sync_messages_with_no_timeout_allowed_(true) { | 405 sync_messages_with_no_timeout_allowed_(true) { |
| 406 StartWatching(); | 406 StartWatching(); |
| 407 } | 407 } |
| 408 | 408 |
| 409 SyncChannel::~SyncChannel() { | 409 SyncChannel::~SyncChannel() { |
| 410 } | 410 } |
| 411 | 411 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // Ideally we only want to watch this object when running a nested message | 532 // Ideally we only want to watch this object when running a nested message |
| 533 // loop. However, we don't know when it exits if there's another nested | 533 // loop. However, we don't know when it exits if there's another nested |
| 534 // message loop running under it or not, so we wouldn't know whether to | 534 // message loop running under it or not, so we wouldn't know whether to |
| 535 // stop or keep watching. So we always watch it, and create the event as | 535 // stop or keep watching. So we always watch it, and create the event as |
| 536 // manual reset since the object watcher might otherwise reset the event | 536 // manual reset since the object watcher might otherwise reset the event |
| 537 // when we're doing a WaitMany. | 537 // when we're doing a WaitMany. |
| 538 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); | 538 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); |
| 539 } | 539 } |
| 540 | 540 |
| 541 } // namespace IPC | 541 } // namespace IPC |
| OLD | NEW |