Skip to content

Commit

Permalink
Revert 274310 "Introduce IPC::ChannelProxy::Create*() and IPC::S..."
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lambroslambrou@chromium.org committed Jun 2, 2014
1 parent d53b685 commit 3b0e466
Show file tree
Hide file tree
Showing 37 changed files with 208 additions and 359 deletions.
5 changes: 3 additions & 2 deletions apps/app_shim/app_shim_host_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ AppShimHost::~AppShimHost() {
void AppShimHost::ServeChannel(const IPC::ChannelHandle& handle) {
DCHECK(CalledOnValidThread());
DCHECK(!channel_.get());
channel_ = IPC::ChannelProxy::CreateServer(
channel_.reset(new IPC::ChannelProxy(
handle,
IPC::Channel::MODE_SERVER,
this,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO).get());
content::BrowserThread::IO).get()));
}

base::FilePath AppShimHost::GetProfilePath() const {
Expand Down
4 changes: 2 additions & 2 deletions apps/app_shim/app_shim_host_manager_browsertest_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ void Send(const T& message) {
app_mode::VerifySocketPermissions(socket_path);

IPC::ChannelHandle handle(socket_path.value());
channel_ = IPC::ChannelProxy::CreateNamedClient(
handle, this, io_thread_.message_loop_proxy().get());
channel_.reset(new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT,
this, io_thread_.message_loop_proxy().get()));
}

TestShimClient::~TestShimClient() {}
Expand Down
7 changes: 5 additions & 2 deletions apps/app_shim/chrome_main_app_mode_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ bool SendFocusApp(apps::AppShimFocusType focus_type,
void AppShimController::CreateChannelAndSendLaunchApp(
const base::FilePath& socket_path) {
IPC::ChannelHandle handle(socket_path.value());
channel_ = IPC::ChannelProxy::CreateNamedClient(
handle, this, g_io_thread->message_loop_proxy().get());
channel_.reset(
new IPC::ChannelProxy(handle,
IPC::Channel::MODE_NAMED_CLIENT,
this,
g_io_thread->message_loop_proxy().get()));

bool launched_by_chrome =
CommandLine::ForCurrentProcess()->HasSwitch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,11 @@ int CloudPrintMockService_Main(SetExpectationsCallback set_expectations) {
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessChannelID);
scoped_ptr<IPC::ChannelProxy> startup_channel;
startup_channel = IPC::ChannelProxy::CreateClient(
startup_channel_name,
&listener,
service_process.IOMessageLoopProxy());
startup_channel.reset(
new IPC::ChannelProxy(startup_channel_name,
IPC::Channel::MODE_CLIENT,
&listener,
service_process.IOMessageLoopProxy()));

main_message_loop.Run();
if (!Mock::VerifyAndClearExpectations(&server))
Expand Down Expand Up @@ -441,8 +442,9 @@ base::ProcessHandle CloudPrintProxyPolicyStartupTest::Launch(
base::StringPrintf("%d.%p.%d",
base::GetCurrentProcId(), this,
base::RandInt(0, std::numeric_limits<int>::max()));
startup_channel_ = IPC::ChannelProxy::CreateServer(
startup_channel_id_, this, IOMessageLoopProxy());
startup_channel_.reset(new IPC::ChannelProxy(
startup_channel_id_, IPC::Channel::MODE_SERVER,
this, IOMessageLoopProxy()));

#if defined(OS_POSIX)
base::FileHandleMappingVector ipc_file_list;
Expand All @@ -464,10 +466,10 @@ void CloudPrintProxyPolicyStartupTest::WaitForConnect() {
EXPECT_TRUE(CheckServiceProcessReady());
EXPECT_TRUE(base::MessageLoopProxy::current().get());
ServiceProcessControl::GetInstance()->SetChannel(
IPC::ChannelProxy::CreateNamedClient(
GetServiceProcessChannel(),
ServiceProcessControl::GetInstance(),
IOMessageLoopProxy()));
new IPC::ChannelProxy(GetServiceProcessChannel(),
IPC::Channel::MODE_NAMED_CLIENT,
ServiceProcessControl::GetInstance(),
IOMessageLoopProxy()));
}

bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) {
Expand Down
7 changes: 4 additions & 3 deletions chrome/browser/service_process/service_process_control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ void ServiceProcessControl::ConnectInternal() {

// TODO(hclam): Handle error connecting to channel.
const IPC::ChannelHandle channel_id = GetServiceProcessChannel();
SetChannel(IPC::ChannelProxy::CreateNamedClient(
SetChannel(new IPC::ChannelProxy(
channel_id,
IPC::Channel::MODE_NAMED_CLIENT,
this,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()));
}

void ServiceProcessControl::SetChannel(scoped_ptr<IPC::ChannelProxy> channel) {
channel_ = channel.Pass();
void ServiceProcessControl::SetChannel(IPC::ChannelProxy* channel) {
channel_.reset(channel);
}

void ServiceProcessControl::RunConnectDoneTasks() {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/service_process/service_process_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class ServiceProcessControl : public IPC::Sender,
void ConnectInternal();

// Takes ownership of the pointer. Split out for testing.
void SetChannel(scoped_ptr<IPC::ChannelProxy> channel);
void SetChannel(IPC::ChannelProxy* channel);

static void RunAllTasksHelper(TaskList* task_list);

Expand Down
5 changes: 3 additions & 2 deletions chrome/service/service_ipc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ bool ServiceIPCServer::Init() {

void ServiceIPCServer::CreateChannel() {
channel_.reset(NULL); // Tear down the existing channel, if any.
channel_= IPC::SyncChannel::CreateNamedServer(
channel_.reset(new IPC::SyncChannel(
channel_handle_,
IPC::Channel::MODE_NAMED_SERVER,
this,
g_service_process->io_thread()->message_loop_proxy().get(),
true,
g_service_process->shutdown_event());
g_service_process->shutdown_event()));
DCHECK(sync_message_filter_.get());
channel_->AddFilter(sync_message_filter_.get());
}
Expand Down
9 changes: 5 additions & 4 deletions components/nacl/browser/nacl_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,10 +905,11 @@ void NaClProcessHost::OnPpapiChannelsCreated(
if (!ipc_proxy_channel_.get()) {
DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type);

ipc_proxy_channel_ = IPC::ChannelProxy::CreateClient(
browser_channel_handle,
NULL,
base::MessageLoopProxy::current().get());
ipc_proxy_channel_.reset(
new IPC::ChannelProxy(browser_channel_handle,
IPC::Channel::MODE_CLIENT,
NULL,
base::MessageLoopProxy::current().get()));
// Create the browser ppapi host and enable PPAPI message dispatching to the
// browser process.
ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess(
Expand Down
6 changes: 3 additions & 3 deletions components/nacl/loader/nacl_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ void NaClListener::Listen() {
std::string channel_name =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessChannelID);
channel_ = IPC::SyncChannel::Create(
this, io_thread_.message_loop_proxy().get(), &shutdown_event_);
channel_.reset(new IPC::SyncChannel(
this, io_thread_.message_loop_proxy().get(), &shutdown_event_));
filter_ = new IPC::SyncMessageFilter(&shutdown_event_);
channel_->AddFilter(filter_.get());
channel_->InitClient(channel_name, true);
channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true);
main_loop_ = base::MessageLoop::current();
main_loop_->Run();
}
Expand Down
5 changes: 3 additions & 2 deletions components/nacl/loader/nacl_trusted_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ NaClTrustedListener::NaClTrustedListener(
const IPC::ChannelHandle& handle,
base::MessageLoopProxy* message_loop_proxy,
base::WaitableEvent* shutdown_event) {
channel_ = IPC::SyncChannel::CreateServer(
handle, this, message_loop_proxy, true, shutdown_event);
channel_.reset(new IPC::SyncChannel(handle, IPC::Channel::MODE_SERVER, this,
message_loop_proxy, true,
shutdown_event));
}

NaClTrustedListener::~NaClTrustedListener() {
Expand Down
4 changes: 2 additions & 2 deletions components/nacl/renderer/manifest_service_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ ManifestServiceChannel::ManifestServiceChannel(
base::WaitableEvent* waitable_event)
: connected_callback_(connected_callback),
delegate_(delegate.Pass()),
channel_(IPC::SyncChannel::CreateClient(
handle, this,
channel_(new IPC::SyncChannel(
handle, IPC::Channel::MODE_CLIENT, this,
content::RenderThread::Get()->GetIOMessageLoopProxy(),
true, waitable_event)),
weak_ptr_factory_(this) {
Expand Down
4 changes: 2 additions & 2 deletions components/nacl/renderer/trusted_plugin_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ TrustedPluginChannel::TrustedPluginChannel(
const base::Callback<void(int32_t)>& connected_callback,
base::WaitableEvent* waitable_event)
: connected_callback_(connected_callback),
channel_(IPC::SyncChannel::CreateClient(
handle, this,
channel_(new IPC::SyncChannel(
handle, IPC::Channel::MODE_CLIENT, this,
content::RenderThread::Get()->GetIOMessageLoopProxy(), true,
waitable_event)) {
}
Expand Down
11 changes: 6 additions & 5 deletions content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,12 @@ bool RenderProcessHostImpl::Init() {
// Setup the IPC channel.
const std::string channel_id =
IPC::Channel::GenerateVerifiedChannelID(std::string());
channel_ = IPC::ChannelProxy::CreateServer(
channel_id,
this,
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::IO).get());
channel_.reset(
new IPC::ChannelProxy(channel_id,
IPC::Channel::MODE_SERVER,
this,
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::IO).get()));

// Setup the Mojo channel.
mojo_application_host_.reset(new MojoApplicationHost());
Expand Down
13 changes: 7 additions & 6 deletions content/child/child_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,13 @@ void ChildThread::Init() {
// the logger, and the logger does not like being created on the IO thread.
IPC::Logging::GetInstance();
#endif
channel_ = IPC::SyncChannel::CreateClient(
channel_name_,
this,
ChildProcess::current()->io_message_loop_proxy(),
true,
ChildProcess::current()->GetShutDownEvent());
channel_.reset(
new IPC::SyncChannel(channel_name_,
IPC::Channel::MODE_CLIENT,
this,
ChildProcess::current()->io_message_loop_proxy(),
true,
ChildProcess::current()->GetShutDownEvent()));
#ifdef IPC_MESSAGE_LOG_ENABLED
if (!in_browser_process_)
IPC::Logging::GetInstance()->SetIPCSender(this);
Expand Down
6 changes: 3 additions & 3 deletions content/child/npapi/np_channel_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ bool NPChannelBase::Init(base::MessageLoopProxy* ipc_message_loop,
return false;
#endif

channel_ = IPC::SyncChannel::Create(
this, ipc_message_loop, shutdown_event);
channel_->InitByMode(channel_handle_, mode_, create_pipe_now);
channel_.reset(new IPC::SyncChannel(
channel_handle_, mode_, this, ipc_message_loop, create_pipe_now,
shutdown_event));

#if defined(OS_POSIX)
// Check the validity of fd for bug investigation. Remove after fixed.
Expand Down
8 changes: 6 additions & 2 deletions content/common/gpu/client/gpu_channel_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ void GpuChannelHost::Connect(const IPC::ChannelHandle& channel_handle,
// Open a channel to the GPU process. We pass NULL as the main listener here
// since we need to filter everything to route it to the right thread.
scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy();
channel_ = IPC::SyncChannel::CreateClient(
channel_handle, NULL, io_loop.get(), true, shutdown_event);
channel_.reset(new IPC::SyncChannel(channel_handle,
IPC::Channel::MODE_CLIENT,
NULL,
io_loop.get(),
true,
shutdown_event));

sync_filter_ = new IPC::SyncMessageFilter(shutdown_event);

Expand Down
5 changes: 3 additions & 2 deletions content/common/gpu/gpu_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,13 @@ void GpuChannel::Init(base::MessageLoopProxy* io_message_loop,
DCHECK(!channel_.get());

// Map renderer ID to a (single) channel to that process.
channel_ = IPC::SyncChannel::CreateServer(
channel_.reset(new IPC::SyncChannel(
channel_id_,
IPC::Channel::MODE_SERVER,
this,
io_message_loop,
false,
shutdown_event);
shutdown_event));

filter_ =
new GpuChannelMessageFilter(weak_factory_.GetWeakPtr(),
Expand Down
90 changes: 10 additions & 80 deletions ipc/ipc_channel_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,79 +304,29 @@ 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)
: 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)
Expand Down Expand Up @@ -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());

Expand Down
Loading

0 comments on commit 3b0e466

Please sign in to comment.