summaryrefslogtreecommitdiffstats
path: root/ipc/mojo
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2015-09-23 20:26:38 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-24 03:28:27 +0000
commit30dc2811d9c106d733cea51f5600875cacba2f80 (patch)
treeb867453e48f95aed038868096f4b57b755acc7a7 /ipc/mojo
parent3a2ac1dd9e42e314c77300864c108ea8be51aadd (diff)
downloadchromium_src-30dc2811d9c106d733cea51f5600875cacba2f80.zip
chromium_src-30dc2811d9c106d733cea51f5600875cacba2f80.tar.gz
chromium_src-30dc2811d9c106d733cea51f5600875cacba2f80.tar.bz2
ipc: Remove unnecessary attachment broker plumbing.
The original design was to pass around an instance of an attachment broker. The new design uses a single global, and no longer needs any plumbing. This CL removes the last vestiges of the plumbing. BUG=493414 Review URL: https://codereview.chromium.org/1354973006 Cr-Commit-Position: refs/heads/master@{#350471}
Diffstat (limited to 'ipc/mojo')
-rw-r--r--ipc/mojo/ipc_channel_mojo.cc60
-rw-r--r--ipc/mojo/ipc_channel_mojo.h21
-rw-r--r--ipc/mojo/ipc_channel_mojo_unittest.cc15
-rw-r--r--ipc/mojo/ipc_mojo_bootstrap.cc5
-rw-r--r--ipc/mojo/ipc_mojo_bootstrap.h5
-rw-r--r--ipc/mojo/ipc_mojo_bootstrap_unittest.cc4
-rw-r--r--ipc/mojo/ipc_mojo_perftest.cc4
7 files changed, 39 insertions, 75 deletions
diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc
index ff20719..a0f3a9d 100644
--- a/ipc/mojo/ipc_channel_mojo.cc
+++ b/ipc/mojo/ipc_channel_mojo.cc
@@ -30,27 +30,21 @@ class MojoChannelFactory : public ChannelFactory {
public:
MojoChannelFactory(scoped_refptr<base::TaskRunner> io_runner,
ChannelHandle channel_handle,
- Channel::Mode mode,
- AttachmentBroker* broker)
- : io_runner_(io_runner),
- channel_handle_(channel_handle),
- mode_(mode),
- broker_(broker) {}
+ Channel::Mode mode)
+ : io_runner_(io_runner), channel_handle_(channel_handle), mode_(mode) {}
std::string GetName() const override {
return channel_handle_.name;
}
scoped_ptr<Channel> BuildChannel(Listener* listener) override {
- return ChannelMojo::Create(io_runner_, channel_handle_, mode_, listener,
- broker_);
+ return ChannelMojo::Create(io_runner_, channel_handle_, mode_, listener);
}
private:
scoped_refptr<base::TaskRunner> io_runner_;
ChannelHandle channel_handle_;
Channel::Mode mode_;
- AttachmentBroker* broker_;
};
//------------------------------------------------------------------------------
@@ -59,8 +53,7 @@ class ClientChannelMojo : public ChannelMojo, public ClientChannel {
public:
ClientChannelMojo(scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
- Listener* listener,
- AttachmentBroker* broker);
+ Listener* listener);
~ClientChannelMojo() override;
// MojoBootstrap::Delegate implementation
void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle) override;
@@ -83,12 +76,10 @@ class ClientChannelMojo : public ChannelMojo, public ClientChannel {
ClientChannelMojo::ClientChannelMojo(scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
- Listener* listener,
- AttachmentBroker* broker)
- : ChannelMojo(io_runner, handle, Channel::MODE_CLIENT, listener, broker),
+ Listener* listener)
+ : ChannelMojo(io_runner, handle, Channel::MODE_CLIENT, listener),
binding_(this),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
ClientChannelMojo::~ClientChannelMojo() {
}
@@ -121,8 +112,7 @@ class ServerChannelMojo : public ChannelMojo {
public:
ServerChannelMojo(scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
- Listener* listener,
- AttachmentBroker* broker);
+ Listener* listener);
~ServerChannelMojo() override;
// MojoBootstrap::Delegate implementation
@@ -147,11 +137,9 @@ class ServerChannelMojo : public ChannelMojo {
ServerChannelMojo::ServerChannelMojo(scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
- Listener* listener,
- AttachmentBroker* broker)
- : ChannelMojo(io_runner, handle, Channel::MODE_SERVER, listener, broker),
- weak_factory_(this) {
-}
+ Listener* listener)
+ : ChannelMojo(io_runner, handle, Channel::MODE_SERVER, listener),
+ weak_factory_(this) {}
ServerChannelMojo::~ServerChannelMojo() {
Close();
@@ -245,15 +233,14 @@ scoped_ptr<ChannelMojo> ChannelMojo::Create(
scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& channel_handle,
Mode mode,
- Listener* listener,
- AttachmentBroker* broker) {
+ Listener* listener) {
switch (mode) {
case Channel::MODE_CLIENT:
return make_scoped_ptr(
- new ClientChannelMojo(io_runner, channel_handle, listener, broker));
+ new ClientChannelMojo(io_runner, channel_handle, listener));
case Channel::MODE_SERVER:
return make_scoped_ptr(
- new ServerChannelMojo(io_runner, channel_handle, listener, broker));
+ new ServerChannelMojo(io_runner, channel_handle, listener));
default:
NOTREACHED();
return nullptr;
@@ -263,26 +250,23 @@ scoped_ptr<ChannelMojo> ChannelMojo::Create(
// static
scoped_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
scoped_refptr<base::TaskRunner> io_runner,
- const ChannelHandle& channel_handle,
- AttachmentBroker* broker) {
- return make_scoped_ptr(new MojoChannelFactory(io_runner, channel_handle,
- Channel::MODE_SERVER, broker));
+ const ChannelHandle& channel_handle) {
+ return make_scoped_ptr(
+ new MojoChannelFactory(io_runner, channel_handle, Channel::MODE_SERVER));
}
// static
scoped_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
scoped_refptr<base::TaskRunner> io_runner,
- const ChannelHandle& channel_handle,
- AttachmentBroker* broker) {
- return make_scoped_ptr(new MojoChannelFactory(io_runner, channel_handle,
- Channel::MODE_CLIENT, broker));
+ const ChannelHandle& channel_handle) {
+ return make_scoped_ptr(
+ new MojoChannelFactory(io_runner, channel_handle, Channel::MODE_CLIENT));
}
ChannelMojo::ChannelMojo(scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
Mode mode,
- Listener* listener,
- AttachmentBroker* broker)
+ Listener* listener)
: listener_(listener),
peer_pid_(base::kNullProcessId),
io_runner_(io_runner),
@@ -291,7 +275,7 @@ ChannelMojo::ChannelMojo(scoped_refptr<base::TaskRunner> io_runner,
weak_factory_(this) {
// Create MojoBootstrap after all members are set as it touches
// ChannelMojo from a different thread.
- bootstrap_ = MojoBootstrap::Create(handle, mode, this, broker);
+ bootstrap_ = MojoBootstrap::Create(handle, mode, this);
if (io_runner == base::MessageLoop::current()->task_runner()) {
InitOnIOThread();
} else {
diff --git a/ipc/mojo/ipc_channel_mojo.h b/ipc/mojo/ipc_channel_mojo.h
index e7b7b76..834fd42 100644
--- a/ipc/mojo/ipc_channel_mojo.h
+++ b/ipc/mojo/ipc_channel_mojo.h
@@ -61,34 +61,22 @@ class IPC_MOJO_EXPORT ChannelMojo
static bool ShouldBeUsed();
// Create ChannelMojo. A bootstrap channel is created as well.
- // |broker| must outlive the newly created channel.
static scoped_ptr<ChannelMojo> Create(
scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& channel_handle,
Mode mode,
- Listener* listener,
- AttachmentBroker* broker);
+ Listener* listener);
// Create a factory object for ChannelMojo.
// The factory is used to create Mojo-based ChannelProxy family.
// |host| must not be null.
- // TODO(erikchen): Remove default parameter for |broker|. It exists only to
- // make the upcoming refactor decomposable into smaller CLs.
- // http://crbug.com/493414.
- // |broker| must outlive the factory and all channels it creates.
static scoped_ptr<ChannelFactory> CreateServerFactory(
scoped_refptr<base::TaskRunner> io_runner,
- const ChannelHandle& channel_handle,
- AttachmentBroker* broker = nullptr);
+ const ChannelHandle& channel_handle);
- // TODO(erikchen): Remove default parameter for |broker|. It exists only to
- // make the upcoming refactor decomposable into smaller CLs.
- // http://crbug.com/493414.
- // |broker| must outlive the factory and all channels it creates.
static scoped_ptr<ChannelFactory> CreateClientFactory(
scoped_refptr<base::TaskRunner> io_runner,
- const ChannelHandle& channel_handle,
- AttachmentBroker* broker = nullptr);
+ const ChannelHandle& channel_handle);
~ChannelMojo() override;
@@ -126,8 +114,7 @@ class IPC_MOJO_EXPORT ChannelMojo
ChannelMojo(scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& channel_handle,
Mode mode,
- Listener* listener,
- AttachmentBroker* broker);
+ Listener* listener);
void CreateMessagingPipe(mojo::embedder::ScopedPlatformHandle handle,
const CreateMessagingPipeCallback& callback);
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc
index 02bdcf1..58d3e9f 100644
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc
@@ -69,9 +69,9 @@ class ListenerThatExpectsOK : public IPC::Listener {
class ChannelClient {
public:
explicit ChannelClient(IPC::Listener* listener, const char* name) {
- channel_ = IPC::ChannelMojo::Create(
- main_message_loop_.task_runner(), IPCTestBase::GetChannelName(name),
- IPC::Channel::MODE_CLIENT, listener, nullptr);
+ channel_ = IPC::ChannelMojo::Create(main_message_loop_.task_runner(),
+ IPCTestBase::GetChannelName(name),
+ IPC::Channel::MODE_CLIENT, listener);
}
void Connect() {
@@ -116,8 +116,7 @@ class IPCChannelMojoTest : public IPCChannelMojoTestBase {
scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
const IPC::ChannelHandle& handle,
base::SequencedTaskRunner* runner) override {
- return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle,
- nullptr);
+ return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle);
}
bool DidStartClient() override {
@@ -225,8 +224,7 @@ class IPCChannelMojoErrorTest : public IPCChannelMojoTestBase {
scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
const IPC::ChannelHandle& handle,
base::SequencedTaskRunner* runner) override {
- return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle,
- nullptr);
+ return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle);
}
bool DidStartClient() override {
@@ -627,8 +625,7 @@ class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase {
scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
const IPC::ChannelHandle& handle,
base::SequencedTaskRunner* runner) override {
- return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle,
- nullptr);
+ return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle);
}
bool DidStartClient() override {
diff --git a/ipc/mojo/ipc_mojo_bootstrap.cc b/ipc/mojo/ipc_mojo_bootstrap.cc
index 1b13082..32579f9 100644
--- a/ipc/mojo/ipc_mojo_bootstrap.cc
+++ b/ipc/mojo/ipc_mojo_bootstrap.cc
@@ -148,8 +148,7 @@ void MojoClientBootstrap::OnChannelConnected(int32_t peer_pid) {
// static
scoped_ptr<MojoBootstrap> MojoBootstrap::Create(ChannelHandle handle,
Channel::Mode mode,
- Delegate* delegate,
- AttachmentBroker* broker) {
+ Delegate* delegate) {
CHECK(mode == Channel::MODE_CLIENT || mode == Channel::MODE_SERVER);
scoped_ptr<MojoBootstrap> self =
mode == Channel::MODE_CLIENT
@@ -157,7 +156,7 @@ scoped_ptr<MojoBootstrap> MojoBootstrap::Create(ChannelHandle handle,
: scoped_ptr<MojoBootstrap>(new MojoServerBootstrap());
scoped_ptr<Channel> bootstrap_channel =
- Channel::Create(handle, mode, self.get(), broker);
+ Channel::Create(handle, mode, self.get());
self->Init(bootstrap_channel.Pass(), delegate);
return self.Pass();
}
diff --git a/ipc/mojo/ipc_mojo_bootstrap.h b/ipc/mojo/ipc_mojo_bootstrap.h
index f22cedc..c1ee64c 100644
--- a/ipc/mojo/ipc_mojo_bootstrap.h
+++ b/ipc/mojo/ipc_mojo_bootstrap.h
@@ -13,8 +13,6 @@
namespace IPC {
-class AttachmentBroker;
-
// MojoBootstrap establishes a bootstrap pipe between two processes in
// Chrome. It creates a native IPC::Channel first, then sends one
// side of a newly created pipe to peer process. The pipe is intended
@@ -39,8 +37,7 @@ class IPC_MOJO_EXPORT MojoBootstrap : public Listener {
// mode as |mode|. The result is notified to passed |delegate|.
static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle,
Channel::Mode mode,
- Delegate* delegate,
- AttachmentBroker* broker);
+ Delegate* delegate);
MojoBootstrap();
~MojoBootstrap() override;
diff --git a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
index 3eabf1f..1c3d7ee 100644
--- a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
+++ b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
@@ -53,7 +53,7 @@ TEST_F(IPCMojoBootstrapTest, MAYBE_Connect) {
TestingDelegate delegate;
scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
- GetTestChannelHandle(), IPC::Channel::MODE_SERVER, &delegate, nullptr);
+ GetTestChannelHandle(), IPC::Channel::MODE_SERVER, &delegate);
ASSERT_TRUE(bootstrap->Connect());
#if defined(OS_POSIX)
@@ -75,7 +75,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCMojoBootstrapTestClient) {
TestingDelegate delegate;
scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
IPCTestBase::GetChannelName("IPCMojoBootstrapTestClient"),
- IPC::Channel::MODE_CLIENT, &delegate, nullptr);
+ IPC::Channel::MODE_CLIENT, &delegate);
bootstrap->Connect();
diff --git a/ipc/mojo/ipc_mojo_perftest.cc b/ipc/mojo/ipc_mojo_perftest.cc
index 17a43a0..e3b91fd 100644
--- a/ipc/mojo/ipc_mojo_perftest.cc
+++ b/ipc/mojo/ipc_mojo_perftest.cc
@@ -36,7 +36,7 @@ public:
scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
const IPC::ChannelHandle& handle,
base::SequencedTaskRunner* runner) override {
- return IPC::ChannelMojo::CreateServerFactory(runner, handle, nullptr);
+ return IPC::ChannelMojo::CreateServerFactory(runner, handle);
}
bool DidStartClient() override {
@@ -82,7 +82,7 @@ scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
IPC::Listener* listener) {
return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create(
task_runner(), IPCTestBase::GetChannelName("PerformanceClient"),
- IPC::Channel::MODE_CLIENT, listener, nullptr));
+ IPC::Channel::MODE_CLIENT, listener));
}
MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {