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

Side by Side Diff: ipc/ipc_sync_channel.cc

Issue 301973003: Introduce IPC::ChannelProxy::Create*() and IPC::SynChannel::Create*() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« 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) 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 DCHECK_EQ(GetSendDoneEvent(), event); 397 DCHECK_EQ(GetSendDoneEvent(), event);
398 base::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 // static
408 scoped_ptr<SyncChannel> SyncChannel::CreateClient(
409 const IPC::ChannelHandle& channel_handle,
410 Listener* listener,
411 base::SingleThreadTaskRunner* ipc_task_runner,
412 bool create_pipe_now,
413 base::WaitableEvent* shutdown_event) {
414 scoped_ptr<SyncChannel> channel = Create(
415 listener, ipc_task_runner, shutdown_event);
416 channel->InitClient(channel_handle, create_pipe_now);
417 return channel.Pass();
418 }
419
darin (slow to review) 2014/05/29 21:38:09 nit: only one new line
420
421 // static
422 scoped_ptr<SyncChannel> SyncChannel::CreateServer(
408 const IPC::ChannelHandle& channel_handle, 423 const IPC::ChannelHandle& channel_handle,
409 Channel::Mode mode,
410 Listener* listener, 424 Listener* listener,
411 base::SingleThreadTaskRunner* ipc_task_runner, 425 base::SingleThreadTaskRunner* ipc_task_runner,
412 bool create_pipe_now, 426 bool create_pipe_now,
413 WaitableEvent* shutdown_event) 427 base::WaitableEvent* shutdown_event) {
414 : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { 428 scoped_ptr<SyncChannel> channel = Create(
415 // The current (listener) thread must be distinct from the IPC thread, or else 429 listener, ipc_task_runner, shutdown_event);
416 // sending synchronous messages will deadlock. 430 channel->InitServer(channel_handle, create_pipe_now);
417 DCHECK_NE(ipc_task_runner, base::ThreadTaskRunnerHandle::Get()); 431 return channel.Pass();
418 ChannelProxy::Init(channel_handle, mode, create_pipe_now); 432 }
419 StartWatching(); 433
434 // static
435 scoped_ptr<SyncChannel> SyncChannel::CreateNamedClient(
436 const IPC::ChannelHandle& channel_handle,
437 Listener* listener,
438 base::SingleThreadTaskRunner* ipc_task_runner,
439 bool create_pipe_now,
440 base::WaitableEvent* shutdown_event) {
441 scoped_ptr<SyncChannel> channel = Create(
442 listener, ipc_task_runner, shutdown_event);
443 channel->InitNamedClient(channel_handle, create_pipe_now);
444 return channel.Pass();
445 }
446
447 // static
448 scoped_ptr<SyncChannel> SyncChannel::CreateNamedServer(
449 const IPC::ChannelHandle& channel_handle,
450 Listener* listener,
451 base::SingleThreadTaskRunner* ipc_task_runner,
452 bool create_pipe_now,
453 base::WaitableEvent* shutdown_event) {
454 scoped_ptr<SyncChannel> channel = Create(
455 listener, ipc_task_runner, shutdown_event);
456 channel->InitNamedServer(channel_handle, create_pipe_now);
457 return channel.Pass();
458 }
459
460 // static
461 scoped_ptr<SyncChannel> SyncChannel::Create(
462 Listener* listener,
463 base::SingleThreadTaskRunner* ipc_task_runner,
464 WaitableEvent* shutdown_event) {
465 return make_scoped_ptr(new SyncChannel(
466 listener, ipc_task_runner, shutdown_event));
420 } 467 }
421 468
422 SyncChannel::SyncChannel( 469 SyncChannel::SyncChannel(
423 Listener* listener, 470 Listener* listener,
424 base::SingleThreadTaskRunner* ipc_task_runner, 471 base::SingleThreadTaskRunner* ipc_task_runner,
425 WaitableEvent* shutdown_event) 472 WaitableEvent* shutdown_event)
426 : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { 473 : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) {
427 // The current (listener) thread must be distinct from the IPC thread, or else 474 // The current (listener) thread must be distinct from the IPC thread, or else
428 // sending synchronous messages will deadlock. 475 // sending synchronous messages will deadlock.
429 DCHECK_NE(ipc_task_runner, base::ThreadTaskRunnerHandle::Get()); 476 DCHECK_NE(ipc_task_runner, base::ThreadTaskRunnerHandle::Get());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // manual reset since the object watcher might otherwise reset the event 603 // manual reset since the object watcher might otherwise reset the event
557 // when we're doing a WaitMany. 604 // when we're doing a WaitMany.
558 dispatch_watcher_callback_ = 605 dispatch_watcher_callback_ =
559 base::Bind(&SyncChannel::OnWaitableEventSignaled, 606 base::Bind(&SyncChannel::OnWaitableEventSignaled,
560 base::Unretained(this)); 607 base::Unretained(this));
561 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), 608 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(),
562 dispatch_watcher_callback_); 609 dispatch_watcher_callback_);
563 } 610 }
564 611
565 } // namespace IPC 612 } // 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