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

Side by Side Diff: ipc/ipc_sync_channel.cc

Issue 8417054: Allow proxy channels to be created without initializing the underlying channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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
« no previous file with comments | « ipc/ipc_sync_channel.h ('k') | ipc/ipc_sync_channel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 372
373 373
374 SyncChannel::SyncChannel( 374 SyncChannel::SyncChannel(
375 const IPC::ChannelHandle& channel_handle, 375 const IPC::ChannelHandle& channel_handle,
376 Channel::Mode mode, 376 Channel::Mode mode,
377 Channel::Listener* listener, 377 Channel::Listener* listener,
378 base::MessageLoopProxy* ipc_message_loop, 378 base::MessageLoopProxy* ipc_message_loop,
379 bool create_pipe_now, 379 bool create_pipe_now,
380 WaitableEvent* shutdown_event) 380 WaitableEvent* shutdown_event)
381 : ChannelProxy( 381 : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)),
382 channel_handle, mode, ipc_message_loop,
383 new SyncContext(listener, ipc_message_loop, shutdown_event),
384 create_pipe_now),
385 sync_messages_with_no_timeout_allowed_(true) { 382 sync_messages_with_no_timeout_allowed_(true) {
386 // Ideally we only want to watch this object when running a nested message 383 ChannelProxy::Init(channel_handle, mode, create_pipe_now);
387 // loop. However, we don't know when it exits if there's another nested 384 StartWatching();
388 // message loop running under it or not, so we wouldn't know whether to 385 }
389 // stop or keep watching. So we always watch it, and create the event as 386
390 // manual reset since the object watcher might otherwise reset the event 387 SyncChannel::SyncChannel(
391 // when we're doing a WaitMany. 388 Channel::Listener* listener,
392 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); 389 base::MessageLoopProxy* ipc_message_loop,
390 WaitableEvent* shutdown_event)
391 : ChannelProxy(new SyncContext(listener, ipc_message_loop, shutdown_event)),
392 sync_messages_with_no_timeout_allowed_(true) {
393 StartWatching();
393 } 394 }
394 395
395 SyncChannel::~SyncChannel() { 396 SyncChannel::~SyncChannel() {
396 } 397 }
397 398
398 void SyncChannel::SetRestrictDispatchToSameChannel(bool value) { 399 void SyncChannel::SetRestrictDispatchToSameChannel(bool value) {
399 sync_context()->set_restrict_dispatch(value); 400 sync_context()->set_restrict_dispatch(value);
400 } 401 }
401 402
402 bool SyncChannel::Send(Message* message) { 403 bool SyncChannel::Send(Message* message) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 508
508 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) { 509 void SyncChannel::OnWaitableEventSignaled(WaitableEvent* event) {
509 DCHECK(event == sync_context()->GetDispatchEvent()); 510 DCHECK(event == sync_context()->GetDispatchEvent());
510 // The call to DispatchMessages might delete this object, so reregister 511 // The call to DispatchMessages might delete this object, so reregister
511 // the object watcher first. 512 // the object watcher first.
512 event->Reset(); 513 event->Reset();
513 dispatch_watcher_.StartWatching(event, this); 514 dispatch_watcher_.StartWatching(event, this);
514 sync_context()->DispatchMessages(); 515 sync_context()->DispatchMessages();
515 } 516 }
516 517
518 void SyncChannel::StartWatching() {
519 // Ideally we only want to watch this object when running a nested message
520 // loop. However, we don't know when it exits if there's another nested
521 // message loop running under it or not, so we wouldn't know whether to
522 // stop or keep watching. So we always watch it, and create the event as
523 // manual reset since the object watcher might otherwise reset the event
524 // when we're doing a WaitMany.
525 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this);
526 }
527
517 } // namespace IPC 528 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_sync_channel.h ('k') | ipc/ipc_sync_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698