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

Unified Diff: ipc/mojo/ipc_channel_mojo.cc

Issue 1069943003: Revert of ChannelMojo: Ensure that it always has ScopedIPCSupport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/mojo/ipc_channel_mojo.h ('k') | ipc/mojo/ipc_channel_mojo_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_channel_mojo.cc
diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc
index 4689e5f64ec7076d9f06b5345310d98d60c45124..f338c6fcdd96df8656681827bbeb08054c049a42 100644
--- a/ipc/mojo/ipc_channel_mojo.cc
+++ b/ipc/mojo/ipc_channel_mojo.cc
@@ -28,26 +28,20 @@
class MojoChannelFactory : public ChannelFactory {
public:
MojoChannelFactory(ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
ChannelHandle channel_handle,
Channel::Mode mode)
- : delegate_(delegate),
- io_runner_(io_runner),
- channel_handle_(channel_handle),
- mode_(mode) {}
+ : delegate_(delegate), 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(delegate_, io_runner_, channel_handle_, mode_,
- listener);
+ return ChannelMojo::Create(delegate_, channel_handle_, mode_, listener);
}
private:
ChannelMojo::Delegate* delegate_;
- scoped_refptr<base::TaskRunner> io_runner_;
ChannelHandle channel_handle_;
Channel::Mode mode_;
};
@@ -59,7 +53,6 @@
public mojo::ErrorHandler {
public:
ClientChannelMojo(ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
Listener* listener);
~ClientChannelMojo() override;
@@ -80,10 +73,9 @@
};
ClientChannelMojo::ClientChannelMojo(ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
Listener* listener)
- : ChannelMojo(delegate, io_runner, handle, Channel::MODE_CLIENT, listener),
+ : ChannelMojo(delegate, handle, Channel::MODE_CLIENT, listener),
binding_(this) {
}
@@ -112,7 +104,6 @@
class ServerChannelMojo : public ChannelMojo, public mojo::ErrorHandler {
public:
ServerChannelMojo(ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
Listener* listener);
~ServerChannelMojo() override;
@@ -135,10 +126,9 @@
};
ServerChannelMojo::ServerChannelMojo(ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
Listener* listener)
- : ChannelMojo(delegate, io_runner, handle, Channel::MODE_SERVER, listener) {
+ : ChannelMojo(delegate, handle, Channel::MODE_SERVER, listener) {
}
ServerChannelMojo::~ServerChannelMojo() {
@@ -206,19 +196,17 @@
}
// static
-scoped_ptr<ChannelMojo> ChannelMojo::Create(
- ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
- const ChannelHandle& channel_handle,
- Mode mode,
- Listener* listener) {
+scoped_ptr<ChannelMojo> ChannelMojo::Create(ChannelMojo::Delegate* delegate,
+ const ChannelHandle& channel_handle,
+ Mode mode,
+ Listener* listener) {
switch (mode) {
case Channel::MODE_CLIENT:
return make_scoped_ptr(
- new ClientChannelMojo(delegate, io_runner, channel_handle, listener));
+ new ClientChannelMojo(delegate, channel_handle, listener));
case Channel::MODE_SERVER:
return make_scoped_ptr(
- new ServerChannelMojo(delegate, io_runner, channel_handle, listener));
+ new ServerChannelMojo(delegate, channel_handle, listener));
default:
NOTREACHED();
return nullptr;
@@ -228,23 +216,20 @@
// static
scoped_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& channel_handle) {
- return make_scoped_ptr(new MojoChannelFactory(
- delegate, io_runner, channel_handle, Channel::MODE_SERVER));
+ return make_scoped_ptr(
+ new MojoChannelFactory(delegate, channel_handle, Channel::MODE_SERVER));
}
// static
scoped_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& channel_handle) {
- return make_scoped_ptr(new MojoChannelFactory(
- delegate, io_runner, channel_handle, Channel::MODE_CLIENT));
+ return make_scoped_ptr(
+ new MojoChannelFactory(delegate, channel_handle, Channel::MODE_CLIENT));
}
ChannelMojo::ChannelMojo(ChannelMojo::Delegate* delegate,
- scoped_refptr<base::TaskRunner> io_runner,
const ChannelHandle& handle,
Mode mode,
Listener* listener)
@@ -255,12 +240,16 @@
// Create MojoBootstrap after all members are set as it touches
// ChannelMojo from a different thread.
bootstrap_ = MojoBootstrap::Create(handle, mode, this);
- if (io_runner == base::MessageLoop::current()->message_loop_proxy()) {
- InitOnIOThread(delegate);
- } else {
- io_runner->PostTask(FROM_HERE,
- base::Bind(&ChannelMojo::InitOnIOThread,
- base::Unretained(this), delegate));
+ if (delegate) {
+ if (delegate->GetIOTaskRunner() ==
+ base::MessageLoop::current()->message_loop_proxy()) {
+ InitDelegate(delegate);
+ } else {
+ delegate->GetIOTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &ChannelMojo::InitDelegate, base::Unretained(this), delegate));
+ }
}
}
@@ -268,11 +257,9 @@
Close();
}
-void ChannelMojo::InitOnIOThread(ChannelMojo::Delegate* delegate) {
+void ChannelMojo::InitDelegate(ChannelMojo::Delegate* delegate) {
ipc_support_.reset(
new ScopedIPCSupport(base::MessageLoop::current()->task_runner()));
- if (!delegate)
- return;
delegate_ = delegate->ToWeakPtr();
delegate_->OnChannelCreated(weak_factory_.GetWeakPtr());
}
« no previous file with comments | « ipc/mojo/ipc_channel_mojo.h ('k') | ipc/mojo/ipc_channel_mojo_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698