diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 20:29:30 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 20:29:30 +0000 |
commit | 3b0e466e530c99fe730a9a5e11dd416c48e052f8 (patch) | |
tree | d4f4d955edc7076fa3408c6625174179da5df72f /ipc | |
parent | d53b6850a51ebedb7496036ae31e5f2dd142efff (diff) | |
download | chromium_src-3b0e466e530c99fe730a9a5e11dd416c48e052f8.zip chromium_src-3b0e466e530c99fe730a9a5e11dd416c48e052f8.tar.gz chromium_src-3b0e466e530c99fe730a9a5e11dd416c48e052f8.tar.bz2 |
Revert 274310 "Introduce IPC::ChannelProxy::Create*() and IPC::S..."
Broke Windows compile:
http://build.chromium.org/p/chromium.win/buildstatus?builder=Win%20x64%20Builder&number=180
FAILED: ninja -t msvc -e environment.x64 -- C:\b\build\goma/gomacc "C:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64\cl.exe" /nologo /showIncludes /FC @obj\remoting\host\win\remoting_core.wts_session_process_delegate.obj.rsp /c ..\..\remoting\host\win\wts_session_process_delegate.cc /Foobj\remoting\host\win\remoting_core.wts_session_process_delegate.obj /Fdobj\remoting\remoting_core.cc.pdb
c:\b\build\slave\win_x64_builder\build\src\remoting\host\win\wts_session_process_delegate.cc(386) : error C2661: 'IPC::ChannelProxy::ChannelProxy' : no overloaded function takes 4 arguments
ninja: build stopped: subcommand failed.
> Introduce IPC::ChannelProxy::Create*() and IPC::SynChannel::Create*()
>
> This change hides constructors of these classes so that we can turn
> them polymorphic classes.
>
> Note that having almost identical ChannelProxy::Init*() isn't great
> and they will be replaced by a factory-like abstraction in coming
> changes.
>
> TEST=none
> R=darin,cpu
> BUG=377980
>
> Review URL: https://codereview.chromium.org/301973003
TBR=morrita@chromium.org
Review URL: https://codereview.chromium.org/312553004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/ipc_channel_proxy.cc | 90 | ||||
-rw-r--r-- | ipc/ipc_channel_proxy.h | 46 | ||||
-rw-r--r-- | ipc/ipc_sync_channel.cc | 64 | ||||
-rw-r--r-- | ipc/ipc_sync_channel.h | 45 | ||||
-rw-r--r-- | ipc/ipc_sync_channel_unittest.cc | 65 | ||||
-rw-r--r-- | ipc/ipc_test_base.cc | 8 |
6 files changed, 71 insertions, 247 deletions
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index cf28ed6..e88bb5d 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -304,56 +304,13 @@ void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) { //----------------------------------------------------------------------------- -// static -scoped_ptr<ChannelProxy> ChannelProxy::Create( - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner) { - return make_scoped_ptr(new ChannelProxy( - listener, ipc_task_runner)); -} - -// static -scoped_ptr<ChannelProxy> ChannelProxy::CreateClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner) { - scoped_ptr<ChannelProxy> channel = Create( - listener, ipc_task_runner); - channel->InitClient(channel_handle, true); - return channel.Pass(); -} - -// static -scoped_ptr<ChannelProxy> ChannelProxy::CreateServer( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner) { - scoped_ptr<ChannelProxy> channel = Create( - listener, ipc_task_runner); - channel->InitServer(channel_handle, true); - return channel.Pass(); -} - -// static -scoped_ptr<ChannelProxy> ChannelProxy::CreateNamedClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner) { - scoped_ptr<ChannelProxy> channel = Create( - listener, ipc_task_runner); - channel->InitNamedClient(channel_handle, true); - return channel.Pass(); -} - -// static -scoped_ptr<ChannelProxy> ChannelProxy::CreateNamedServer( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner) { - scoped_ptr<ChannelProxy> channel = Create( - listener, ipc_task_runner); - channel->InitNamedServer(channel_handle, true); - return channel.Pass(); +ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, + Channel::Mode mode, + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner) + : context_(new Context(listener, ipc_task_runner)), + did_init_(false) { + Init(channel_handle, mode, true); } ChannelProxy::ChannelProxy(Context* context) @@ -361,22 +318,15 @@ ChannelProxy::ChannelProxy(Context* context) did_init_(false) { } -ChannelProxy::ChannelProxy(Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner) - : context_(new Context(listener, ipc_task_runner)), - did_init_(false) { -} - ChannelProxy::~ChannelProxy() { DCHECK(CalledOnValidThread()); Close(); } -void ChannelProxy::InitByMode( - const IPC::ChannelHandle& channel_handle, - Channel::Mode mode, - bool create_pipe_now) { +void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, + Channel::Mode mode, + bool create_pipe_now) { DCHECK(CalledOnValidThread()); DCHECK(!did_init_); #if defined(OS_POSIX) @@ -408,26 +358,6 @@ void ChannelProxy::InitByMode( did_init_ = true; } -void ChannelProxy::InitClient(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now) { - InitByMode(channel_handle, Channel::MODE_CLIENT, create_pipe_now); -} - -void ChannelProxy::InitServer(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now) { - InitByMode(channel_handle, Channel::MODE_SERVER, create_pipe_now); -} - -void ChannelProxy::InitNamedClient(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now) { - InitByMode(channel_handle, Channel::MODE_NAMED_CLIENT, create_pipe_now); -} - -void ChannelProxy::InitNamedServer(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now) { - InitByMode(channel_handle, Channel::MODE_NAMED_SERVER, create_pipe_now); -} - void ChannelProxy::Close() { DCHECK(CalledOnValidThread()); diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h index d1f270d..0a3a5d2 100644 --- a/ipc/ipc_channel_proxy.h +++ b/ipc/ipc_channel_proxy.h @@ -64,31 +64,10 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { // on the background thread. Any message not handled by the filter will be // dispatched to the listener. The given task runner correspond to a thread // on which IPC::Channel is created and used (e.g. IO thread). - // The naming pattern follows IPC::Channel. The Create() does not create - // underlying channel and let Init*() do it. - static scoped_ptr<ChannelProxy> Create( - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner); - - static scoped_ptr<ChannelProxy> CreateClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner); - - static scoped_ptr<ChannelProxy> CreateServer( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner); - - static scoped_ptr<ChannelProxy> CreateNamedClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner); - - static scoped_ptr<ChannelProxy> CreateNamedServer( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner); + ChannelProxy(const IPC::ChannelHandle& channel_handle, + Channel::Mode mode, + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner); virtual ~ChannelProxy(); @@ -96,17 +75,8 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { // proxy that was not initialized in its constructor. If create_pipe_now is // true, the pipe is created synchronously. Otherwise it's created on the IO // thread. - // The naming pattern follows IPC::Channel::Create*(). - void InitByMode(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, - bool create_pipe_now); - void InitClient(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now); - void InitServer(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now); - void InitNamedClient(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now); - void InitNamedServer(const IPC::ChannelHandle& channel_handle, - bool create_pipe_now); + void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, + bool create_pipe_now); // Close the IPC::Channel. This operation completes asynchronously, once the // background thread processes the command to close the channel. It is ok to @@ -154,10 +124,6 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { // to the internal state. ChannelProxy(Context* context); - ChannelProxy(Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner); - - // Used internally to hold state that is referenced on the IPC thread. class Context : public base::RefCountedThreadSafe<Context>, public Listener { diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc index 32f8619..0e0018c 100644 --- a/ipc/ipc_sync_channel.cc +++ b/ipc/ipc_sync_channel.cc @@ -404,65 +404,19 @@ base::WaitableEventWatcher::EventCallback return base::Bind(&SyncChannel::SyncContext::OnWaitableEventSignaled, this); } -// static -scoped_ptr<SyncChannel> SyncChannel::CreateClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - bool create_pipe_now, - base::WaitableEvent* shutdown_event) { - scoped_ptr<SyncChannel> channel = Create( - listener, ipc_task_runner, shutdown_event); - channel->InitClient(channel_handle, create_pipe_now); - return channel.Pass(); -} - -// static -scoped_ptr<SyncChannel> SyncChannel::CreateServer( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - bool create_pipe_now, - base::WaitableEvent* shutdown_event) { - scoped_ptr<SyncChannel> channel = Create( - listener, ipc_task_runner, shutdown_event); - channel->InitServer(channel_handle, create_pipe_now); - return channel.Pass(); -} - -// static -scoped_ptr<SyncChannel> SyncChannel::CreateNamedClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - bool create_pipe_now, - base::WaitableEvent* shutdown_event) { - scoped_ptr<SyncChannel> channel = Create( - listener, ipc_task_runner, shutdown_event); - channel->InitNamedClient(channel_handle, create_pipe_now); - return channel.Pass(); -} - -// static -scoped_ptr<SyncChannel> SyncChannel::CreateNamedServer( +SyncChannel::SyncChannel( const IPC::ChannelHandle& channel_handle, + Channel::Mode mode, Listener* listener, base::SingleThreadTaskRunner* ipc_task_runner, bool create_pipe_now, - base::WaitableEvent* shutdown_event) { - scoped_ptr<SyncChannel> channel = Create( - listener, ipc_task_runner, shutdown_event); - channel->InitNamedServer(channel_handle, create_pipe_now); - return channel.Pass(); -} - -// static -scoped_ptr<SyncChannel> SyncChannel::Create( - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - WaitableEvent* shutdown_event) { - return make_scoped_ptr(new SyncChannel( - listener, ipc_task_runner, shutdown_event)); + WaitableEvent* shutdown_event) + : ChannelProxy(new SyncContext(listener, ipc_task_runner, shutdown_event)) { + // The current (listener) thread must be distinct from the IPC thread, or else + // sending synchronous messages will deadlock. + DCHECK_NE(ipc_task_runner, base::ThreadTaskRunnerHandle::Get()); + ChannelProxy::Init(channel_handle, mode, create_pipe_now); + StartWatching(); } SyncChannel::SyncChannel( diff --git a/ipc/ipc_sync_channel.h b/ipc/ipc_sync_channel.h index 9ae3fd9..f18fcff9 100644 --- a/ipc/ipc_sync_channel.h +++ b/ipc/ipc_sync_channel.h @@ -66,42 +66,19 @@ class IPC_EXPORT SyncChannel : public ChannelProxy { // Creates and initializes a sync channel. If create_pipe_now is specified, // the channel will be initialized synchronously. - // The naming pattern follows IPC::Channel. - static scoped_ptr<SyncChannel> CreateClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - bool create_pipe_now, - base::WaitableEvent* shutdown_event); - - static scoped_ptr<SyncChannel> CreateServer( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - bool create_pipe_now, - base::WaitableEvent* shutdown_event); - - static scoped_ptr<SyncChannel> CreateNamedClient( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - bool create_pipe_now, - base::WaitableEvent* shutdown_event); - - static scoped_ptr<SyncChannel> CreateNamedServer( - const IPC::ChannelHandle& channel_handle, - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - bool create_pipe_now, - base::WaitableEvent* shutdown_event); + SyncChannel(const IPC::ChannelHandle& channel_handle, + Channel::Mode mode, + Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner, + bool create_pipe_now, + base::WaitableEvent* shutdown_event); // Creates an uninitialized sync channel. Call ChannelProxy::Init to // initialize the channel. This two-step setup allows message filters to be // added before any messages are sent or received. - static scoped_ptr<SyncChannel> Create( - Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - base::WaitableEvent* shutdown_event); + SyncChannel(Listener* listener, + base::SingleThreadTaskRunner* ipc_task_runner, + base::WaitableEvent* shutdown_event); virtual ~SyncChannel(); @@ -211,10 +188,6 @@ class IPC_EXPORT SyncChannel : public ChannelProxy { }; private: - SyncChannel(Listener* listener, - base::SingleThreadTaskRunner* ipc_task_runner, - base::WaitableEvent* shutdown_event); - void OnWaitableEventSignaled(base::WaitableEvent* arg); SyncContext* sync_context() { diff --git a/ipc/ipc_sync_channel_unittest.cc b/ipc/ipc_sync_channel_unittest.cc index 33653c7..ca8d5d7 100644 --- a/ipc/ipc_sync_channel_unittest.cc +++ b/ipc/ipc_sync_channel_unittest.cc @@ -151,12 +151,12 @@ class Worker : public Listener, public Sender { } virtual SyncChannel* CreateChannel() { - scoped_ptr<SyncChannel> channel = SyncChannel::Create( - this, - ipc_thread_.message_loop_proxy().get(), - &shutdown_event_); - channel->InitByMode(channel_name_, mode_, true); - return channel.release(); + return new SyncChannel(channel_name_, + mode_, + this, + ipc_thread_.message_loop_proxy().get(), + true, + &shutdown_event_); } base::Thread* ListenerThread() { @@ -324,10 +324,9 @@ class TwoStepServer : public Worker { } virtual SyncChannel* CreateChannel() OVERRIDE { - SyncChannel* channel = SyncChannel::Create( - this, ipc_thread().message_loop_proxy().get(), - shutdown_event()).release(); - channel->InitByMode(channel_name(), mode(), create_pipe_now_); + SyncChannel* channel = new SyncChannel( + this, ipc_thread().message_loop_proxy().get(), shutdown_event()); + channel->Init(channel_name(), mode(), create_pipe_now_); return channel; } @@ -346,10 +345,9 @@ class TwoStepClient : public Worker { } virtual SyncChannel* CreateChannel() OVERRIDE { - SyncChannel* channel = SyncChannel::Create( - this, ipc_thread().message_loop_proxy().get(), - shutdown_event()).release(); - channel->InitByMode(channel_name(), mode(), create_pipe_now_); + SyncChannel* channel = new SyncChannel( + this, ipc_thread().message_loop_proxy().get(), shutdown_event()); + channel->Init(channel_name(), mode(), create_pipe_now_); return channel; } @@ -1137,12 +1135,13 @@ class RestrictedDispatchClient : public Worker { else LOG(ERROR) << "Send failed to dispatch incoming message on same channel"; - non_restricted_channel_ = - SyncChannel::CreateClient("non_restricted_channel", - this, - ipc_thread().message_loop_proxy().get(), - true, - shutdown_event()); + non_restricted_channel_.reset( + new SyncChannel("non_restricted_channel", + Channel::MODE_CLIENT, + this, + ipc_thread().message_loop_proxy().get(), + true, + shutdown_event())); server_->ListenerThread()->message_loop()->PostTask( FROM_HERE, base::Bind(&RestrictedDispatchServer::OnDoPing, server_, 2)); @@ -1527,12 +1526,13 @@ class RestrictedDispatchPipeWorker : public Worker { if (is_first()) event1_->Signal(); event2_->Wait(); - other_channel_ = SyncChannel::CreateClient( - other_channel_name_, - this, - ipc_thread().message_loop_proxy().get(), - true, - shutdown_event()); + other_channel_.reset( + new SyncChannel(other_channel_name_, + Channel::MODE_CLIENT, + this, + ipc_thread().message_loop_proxy().get(), + true, + shutdown_event())); other_channel_->SetRestrictDispatchChannelGroup(group_); if (!is_first()) { event1_->Signal(); @@ -1606,12 +1606,13 @@ class ReentrantReplyServer1 : public Worker { server_ready_(server_ready) { } virtual void Run() OVERRIDE { - server2_channel_ = SyncChannel::CreateClient( - "reentrant_reply2", - this, - ipc_thread().message_loop_proxy().get(), - true, - shutdown_event()); + server2_channel_.reset( + new SyncChannel("reentrant_reply2", + Channel::MODE_CLIENT, + this, + ipc_thread().message_loop_proxy().get(), + true, + shutdown_event())); server_ready_->Signal(); Message* msg = new SyncChannelTestMsg_Reentrant1(); server2_channel_->Send(msg); diff --git a/ipc/ipc_test_base.cc b/ipc/ipc_test_base.cc index 3d4ca88..ca45d16 100644 --- a/ipc/ipc_test_base.cc +++ b/ipc/ipc_test_base.cc @@ -77,10 +77,10 @@ void IPCTestBase::CreateChannelProxy( base::SingleThreadTaskRunner* ipc_task_runner) { CHECK(!channel_.get()); CHECK(!channel_proxy_.get()); - channel_proxy_ = IPC::ChannelProxy::CreateServer( - GetChannelName(test_client_name_), - listener, - ipc_task_runner); + channel_proxy_.reset(new IPC::ChannelProxy(GetChannelName(test_client_name_), + IPC::Channel::MODE_SERVER, + listener, + ipc_task_runner)); } void IPCTestBase::DestroyChannelProxy() { |