ChannelMojo: Ensure that it always has ScopedIPCSupport
ChannelMojo has ScopedIPCSupport, but it is instantiated only in in-process mode. This CL lets it always instantiate to make it clear that ChannelInfo is protected by the ScopedIPCSupport. It simplifies the relationship between the support object and the channel, and makes the lifecycle invariant reasonable. With this change, we no longer need to protect ChannelMojo with ScopedIPCSupport on its client side. Now it's built-in. Note that this is a speculative fix of fuzzer generated crash, where Mojo channel related globals are gone before when channel mojo is being destroyed. BUG=473438 R=viettrungluu@chromium.org, rockot@chromium.org Committed: https://crrev.com/808706e71c213c916815e967e3156cae64d12c00 Cr-Commit-Position: refs/heads/master@{#324308} Review URL: https://codereview.chromium.org/1054253005 Cr-Commit-Position: refs/heads/master@{#324488}
This commit is contained in:
content
browser
renderer_host
child
test
ipc/mojo
ipc_channel_mojo.ccipc_channel_mojo.hipc_channel_mojo_host.ccipc_channel_mojo_unittest.ccipc_mojo_perftest.cc
tools/ipc_fuzzer/message_replay
@@ -703,11 +703,10 @@ scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy(
|
|||||||
channel_mojo_host_.reset(new IPC::ChannelMojoHost(mojo_task_runner));
|
channel_mojo_host_.reset(new IPC::ChannelMojoHost(mojo_task_runner));
|
||||||
}
|
}
|
||||||
|
|
||||||
return IPC::ChannelProxy::Create(
|
return IPC::ChannelProxy::Create(IPC::ChannelMojo::CreateServerFactory(
|
||||||
IPC::ChannelMojo::CreateServerFactory(
|
channel_mojo_host_->channel_delegate(),
|
||||||
channel_mojo_host_->channel_delegate(), channel_id),
|
mojo_task_runner, channel_id),
|
||||||
this,
|
this, runner.get());
|
||||||
runner.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return IPC::ChannelProxy::Create(
|
return IPC::ChannelProxy::Create(
|
||||||
|
@@ -56,7 +56,6 @@
|
|||||||
#include "ipc/ipc_sync_channel.h"
|
#include "ipc/ipc_sync_channel.h"
|
||||||
#include "ipc/ipc_sync_message_filter.h"
|
#include "ipc/ipc_sync_message_filter.h"
|
||||||
#include "ipc/mojo/ipc_channel_mojo.h"
|
#include "ipc/mojo/ipc_channel_mojo.h"
|
||||||
#include "ipc/mojo/scoped_ipc_support.h"
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "content/common/handle_enumerator_win.h"
|
#include "content/common/handle_enumerator_win.h"
|
||||||
@@ -205,45 +204,6 @@ ChildThread* ChildThread::Get() {
|
|||||||
return ChildThreadImpl::current();
|
return ChildThreadImpl::current();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mojo client channel delegate to be used in single process mode.
|
|
||||||
class ChildThreadImpl::SingleProcessChannelDelegate
|
|
||||||
: public IPC::ChannelMojo::Delegate {
|
|
||||||
public:
|
|
||||||
explicit SingleProcessChannelDelegate(
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> io_runner)
|
|
||||||
: io_runner_(io_runner), weak_factory_(this) {}
|
|
||||||
|
|
||||||
~SingleProcessChannelDelegate() override {}
|
|
||||||
|
|
||||||
base::WeakPtr<IPC::ChannelMojo::Delegate> ToWeakPtr() override {
|
|
||||||
return weak_factory_.GetWeakPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<base::TaskRunner> GetIOTaskRunner() override {
|
|
||||||
return io_runner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnChannelCreated(base::WeakPtr<IPC::ChannelMojo> channel) override {}
|
|
||||||
|
|
||||||
void DeleteSoon() {
|
|
||||||
io_runner_->PostTask(
|
|
||||||
FROM_HERE,
|
|
||||||
base::Bind(&base::DeletePointer<SingleProcessChannelDelegate>,
|
|
||||||
base::Unretained(this)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> io_runner_;
|
|
||||||
base::WeakPtrFactory<IPC::ChannelMojo::Delegate> weak_factory_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(SingleProcessChannelDelegate);
|
|
||||||
};
|
|
||||||
|
|
||||||
void ChildThreadImpl::SingleProcessChannelDelegateDeleter::operator()(
|
|
||||||
SingleProcessChannelDelegate* delegate) const {
|
|
||||||
delegate->DeleteSoon();
|
|
||||||
}
|
|
||||||
|
|
||||||
ChildThreadImpl::Options::Options()
|
ChildThreadImpl::Options::Options()
|
||||||
: channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
: channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
||||||
switches::kProcessChannelID)),
|
switches::kProcessChannelID)),
|
||||||
@@ -321,15 +281,9 @@ void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) {
|
|||||||
VLOG(1) << "Mojo is enabled on child";
|
VLOG(1) << "Mojo is enabled on child";
|
||||||
scoped_refptr<base::SequencedTaskRunner> io_task_runner = GetIOTaskRunner();
|
scoped_refptr<base::SequencedTaskRunner> io_task_runner = GetIOTaskRunner();
|
||||||
DCHECK(io_task_runner);
|
DCHECK(io_task_runner);
|
||||||
if (IsInBrowserProcess())
|
channel_->Init(IPC::ChannelMojo::CreateClientFactory(
|
||||||
single_process_channel_delegate_.reset(
|
nullptr, io_task_runner, channel_name_),
|
||||||
new SingleProcessChannelDelegate(io_task_runner));
|
create_pipe_now);
|
||||||
ipc_support_.reset(new IPC::ScopedIPCSupport(io_task_runner));
|
|
||||||
channel_->Init(
|
|
||||||
IPC::ChannelMojo::CreateClientFactory(
|
|
||||||
single_process_channel_delegate_.get(),
|
|
||||||
channel_name_),
|
|
||||||
create_pipe_now);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -235,15 +235,6 @@ class CONTENT_EXPORT ChildThreadImpl
|
|||||||
|
|
||||||
void EnsureConnected();
|
void EnsureConnected();
|
||||||
|
|
||||||
class SingleProcessChannelDelegate;
|
|
||||||
class SingleProcessChannelDelegateDeleter {
|
|
||||||
public:
|
|
||||||
void operator()(SingleProcessChannelDelegate* delegate) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
|
|
||||||
scoped_ptr<SingleProcessChannelDelegate, SingleProcessChannelDelegateDeleter>
|
|
||||||
single_process_channel_delegate_;
|
|
||||||
scoped_ptr<MojoApplication> mojo_application_;
|
scoped_ptr<MojoApplication> mojo_application_;
|
||||||
|
|
||||||
std::string channel_name_;
|
std::string channel_name_;
|
||||||
|
@@ -54,6 +54,7 @@ void RenderThreadImplBrowserIPCTestHelper::SetupMojo() {
|
|||||||
|
|
||||||
channel_ = IPC::ChannelProxy::Create(
|
channel_ = IPC::ChannelProxy::Create(
|
||||||
IPC::ChannelMojo::CreateServerFactory(mojo_host_->channel_delegate(),
|
IPC::ChannelMojo::CreateServerFactory(mojo_host_->channel_delegate(),
|
||||||
|
ipc_thread_->task_runner(),
|
||||||
channel_id_),
|
channel_id_),
|
||||||
dummy_listener_.get(), ipc_thread_->task_runner());
|
dummy_listener_.get(), ipc_thread_->task_runner());
|
||||||
|
|
||||||
|
@@ -28,20 +28,26 @@ namespace {
|
|||||||
class MojoChannelFactory : public ChannelFactory {
|
class MojoChannelFactory : public ChannelFactory {
|
||||||
public:
|
public:
|
||||||
MojoChannelFactory(ChannelMojo::Delegate* delegate,
|
MojoChannelFactory(ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
ChannelHandle channel_handle,
|
ChannelHandle channel_handle,
|
||||||
Channel::Mode mode)
|
Channel::Mode mode)
|
||||||
: delegate_(delegate), channel_handle_(channel_handle), mode_(mode) {}
|
: delegate_(delegate),
|
||||||
|
io_runner_(io_runner),
|
||||||
|
channel_handle_(channel_handle),
|
||||||
|
mode_(mode) {}
|
||||||
|
|
||||||
std::string GetName() const override {
|
std::string GetName() const override {
|
||||||
return channel_handle_.name;
|
return channel_handle_.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<Channel> BuildChannel(Listener* listener) override {
|
scoped_ptr<Channel> BuildChannel(Listener* listener) override {
|
||||||
return ChannelMojo::Create(delegate_, channel_handle_, mode_, listener);
|
return ChannelMojo::Create(delegate_, io_runner_, channel_handle_, mode_,
|
||||||
|
listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ChannelMojo::Delegate* delegate_;
|
ChannelMojo::Delegate* delegate_;
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner_;
|
||||||
ChannelHandle channel_handle_;
|
ChannelHandle channel_handle_;
|
||||||
Channel::Mode mode_;
|
Channel::Mode mode_;
|
||||||
};
|
};
|
||||||
@@ -53,6 +59,7 @@ class ClientChannelMojo : public ChannelMojo,
|
|||||||
public mojo::ErrorHandler {
|
public mojo::ErrorHandler {
|
||||||
public:
|
public:
|
||||||
ClientChannelMojo(ChannelMojo::Delegate* delegate,
|
ClientChannelMojo(ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& handle,
|
const ChannelHandle& handle,
|
||||||
Listener* listener);
|
Listener* listener);
|
||||||
~ClientChannelMojo() override;
|
~ClientChannelMojo() override;
|
||||||
@@ -73,9 +80,10 @@ class ClientChannelMojo : public ChannelMojo,
|
|||||||
};
|
};
|
||||||
|
|
||||||
ClientChannelMojo::ClientChannelMojo(ChannelMojo::Delegate* delegate,
|
ClientChannelMojo::ClientChannelMojo(ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& handle,
|
const ChannelHandle& handle,
|
||||||
Listener* listener)
|
Listener* listener)
|
||||||
: ChannelMojo(delegate, handle, Channel::MODE_CLIENT, listener),
|
: ChannelMojo(delegate, io_runner, handle, Channel::MODE_CLIENT, listener),
|
||||||
binding_(this) {
|
binding_(this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +112,7 @@ void ClientChannelMojo::Init(
|
|||||||
class ServerChannelMojo : public ChannelMojo, public mojo::ErrorHandler {
|
class ServerChannelMojo : public ChannelMojo, public mojo::ErrorHandler {
|
||||||
public:
|
public:
|
||||||
ServerChannelMojo(ChannelMojo::Delegate* delegate,
|
ServerChannelMojo(ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& handle,
|
const ChannelHandle& handle,
|
||||||
Listener* listener);
|
Listener* listener);
|
||||||
~ServerChannelMojo() override;
|
~ServerChannelMojo() override;
|
||||||
@@ -126,9 +135,10 @@ class ServerChannelMojo : public ChannelMojo, public mojo::ErrorHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ServerChannelMojo::ServerChannelMojo(ChannelMojo::Delegate* delegate,
|
ServerChannelMojo::ServerChannelMojo(ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& handle,
|
const ChannelHandle& handle,
|
||||||
Listener* listener)
|
Listener* listener)
|
||||||
: ChannelMojo(delegate, handle, Channel::MODE_SERVER, listener) {
|
: ChannelMojo(delegate, io_runner, handle, Channel::MODE_SERVER, listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerChannelMojo::~ServerChannelMojo() {
|
ServerChannelMojo::~ServerChannelMojo() {
|
||||||
@@ -196,17 +206,19 @@ bool ChannelMojo::ShouldBeUsed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
scoped_ptr<ChannelMojo> ChannelMojo::Create(ChannelMojo::Delegate* delegate,
|
scoped_ptr<ChannelMojo> ChannelMojo::Create(
|
||||||
const ChannelHandle& channel_handle,
|
ChannelMojo::Delegate* delegate,
|
||||||
Mode mode,
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
Listener* listener) {
|
const ChannelHandle& channel_handle,
|
||||||
|
Mode mode,
|
||||||
|
Listener* listener) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case Channel::MODE_CLIENT:
|
case Channel::MODE_CLIENT:
|
||||||
return make_scoped_ptr(
|
return make_scoped_ptr(
|
||||||
new ClientChannelMojo(delegate, channel_handle, listener));
|
new ClientChannelMojo(delegate, io_runner, channel_handle, listener));
|
||||||
case Channel::MODE_SERVER:
|
case Channel::MODE_SERVER:
|
||||||
return make_scoped_ptr(
|
return make_scoped_ptr(
|
||||||
new ServerChannelMojo(delegate, channel_handle, listener));
|
new ServerChannelMojo(delegate, io_runner, channel_handle, listener));
|
||||||
default:
|
default:
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -216,20 +228,23 @@ scoped_ptr<ChannelMojo> ChannelMojo::Create(ChannelMojo::Delegate* delegate,
|
|||||||
// static
|
// static
|
||||||
scoped_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
|
scoped_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
|
||||||
ChannelMojo::Delegate* delegate,
|
ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& channel_handle) {
|
const ChannelHandle& channel_handle) {
|
||||||
return make_scoped_ptr(
|
return make_scoped_ptr(new MojoChannelFactory(
|
||||||
new MojoChannelFactory(delegate, channel_handle, Channel::MODE_SERVER));
|
delegate, io_runner, channel_handle, Channel::MODE_SERVER));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
scoped_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
|
scoped_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
|
||||||
ChannelMojo::Delegate* delegate,
|
ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& channel_handle) {
|
const ChannelHandle& channel_handle) {
|
||||||
return make_scoped_ptr(
|
return make_scoped_ptr(new MojoChannelFactory(
|
||||||
new MojoChannelFactory(delegate, channel_handle, Channel::MODE_CLIENT));
|
delegate, io_runner, channel_handle, Channel::MODE_CLIENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelMojo::ChannelMojo(ChannelMojo::Delegate* delegate,
|
ChannelMojo::ChannelMojo(ChannelMojo::Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& handle,
|
const ChannelHandle& handle,
|
||||||
Mode mode,
|
Mode mode,
|
||||||
Listener* listener)
|
Listener* listener)
|
||||||
@@ -240,16 +255,12 @@ ChannelMojo::ChannelMojo(ChannelMojo::Delegate* delegate,
|
|||||||
// Create MojoBootstrap after all members are set as it touches
|
// Create MojoBootstrap after all members are set as it touches
|
||||||
// ChannelMojo from a different thread.
|
// ChannelMojo from a different thread.
|
||||||
bootstrap_ = MojoBootstrap::Create(handle, mode, this);
|
bootstrap_ = MojoBootstrap::Create(handle, mode, this);
|
||||||
if (delegate) {
|
if (io_runner == base::MessageLoop::current()->message_loop_proxy()) {
|
||||||
if (delegate->GetIOTaskRunner() ==
|
InitOnIOThread(delegate);
|
||||||
base::MessageLoop::current()->message_loop_proxy()) {
|
} else {
|
||||||
InitDelegate(delegate);
|
io_runner->PostTask(FROM_HERE,
|
||||||
} else {
|
base::Bind(&ChannelMojo::InitOnIOThread,
|
||||||
delegate->GetIOTaskRunner()->PostTask(
|
base::Unretained(this), delegate));
|
||||||
FROM_HERE,
|
|
||||||
base::Bind(
|
|
||||||
&ChannelMojo::InitDelegate, base::Unretained(this), delegate));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,9 +268,11 @@ ChannelMojo::~ChannelMojo() {
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelMojo::InitDelegate(ChannelMojo::Delegate* delegate) {
|
void ChannelMojo::InitOnIOThread(ChannelMojo::Delegate* delegate) {
|
||||||
ipc_support_.reset(
|
ipc_support_.reset(
|
||||||
new ScopedIPCSupport(base::MessageLoop::current()->task_runner()));
|
new ScopedIPCSupport(base::MessageLoop::current()->task_runner()));
|
||||||
|
if (!delegate)
|
||||||
|
return;
|
||||||
delegate_ = delegate->ToWeakPtr();
|
delegate_ = delegate->ToWeakPtr();
|
||||||
delegate_->OnChannelCreated(weak_factory_.GetWeakPtr());
|
delegate_->OnChannelCreated(weak_factory_.GetWeakPtr());
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,6 @@ class IPC_MOJO_EXPORT ChannelMojo
|
|||||||
public:
|
public:
|
||||||
virtual ~Delegate() {}
|
virtual ~Delegate() {}
|
||||||
virtual base::WeakPtr<Delegate> ToWeakPtr() = 0;
|
virtual base::WeakPtr<Delegate> ToWeakPtr() = 0;
|
||||||
virtual scoped_refptr<base::TaskRunner> GetIOTaskRunner() = 0;
|
|
||||||
virtual void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) = 0;
|
virtual void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,20 +62,24 @@ class IPC_MOJO_EXPORT ChannelMojo
|
|||||||
|
|
||||||
// Create ChannelMojo. A bootstrap channel is created as well.
|
// Create ChannelMojo. A bootstrap channel is created as well.
|
||||||
// |host| must not be null for server channels.
|
// |host| must not be null for server channels.
|
||||||
static scoped_ptr<ChannelMojo> Create(Delegate* delegate,
|
static scoped_ptr<ChannelMojo> Create(
|
||||||
const ChannelHandle& channel_handle,
|
Delegate* delegate,
|
||||||
Mode mode,
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
Listener* listener);
|
const ChannelHandle& channel_handle,
|
||||||
|
Mode mode,
|
||||||
|
Listener* listener);
|
||||||
|
|
||||||
// Create a factory object for ChannelMojo.
|
// Create a factory object for ChannelMojo.
|
||||||
// The factory is used to create Mojo-based ChannelProxy family.
|
// The factory is used to create Mojo-based ChannelProxy family.
|
||||||
// |host| must not be null.
|
// |host| must not be null.
|
||||||
static scoped_ptr<ChannelFactory> CreateServerFactory(
|
static scoped_ptr<ChannelFactory> CreateServerFactory(
|
||||||
Delegate* delegate,
|
Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& channel_handle);
|
const ChannelHandle& channel_handle);
|
||||||
|
|
||||||
static scoped_ptr<ChannelFactory> CreateClientFactory(
|
static scoped_ptr<ChannelFactory> CreateClientFactory(
|
||||||
Delegate* delegate,
|
Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& channel_handle);
|
const ChannelHandle& channel_handle);
|
||||||
|
|
||||||
~ChannelMojo() override;
|
~ChannelMojo() override;
|
||||||
@@ -115,6 +118,7 @@ class IPC_MOJO_EXPORT ChannelMojo
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
ChannelMojo(Delegate* delegate,
|
ChannelMojo(Delegate* delegate,
|
||||||
|
scoped_refptr<base::TaskRunner> io_runner,
|
||||||
const ChannelHandle& channel_handle,
|
const ChannelHandle& channel_handle,
|
||||||
Mode mode,
|
Mode mode,
|
||||||
Listener* listener);
|
Listener* listener);
|
||||||
@@ -136,7 +140,7 @@ class IPC_MOJO_EXPORT ChannelMojo
|
|||||||
// notifications invoked by them.
|
// notifications invoked by them.
|
||||||
typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter;
|
typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter;
|
||||||
|
|
||||||
void InitDelegate(ChannelMojo::Delegate* delegate);
|
void InitOnIOThread(ChannelMojo::Delegate* delegate);
|
||||||
|
|
||||||
scoped_ptr<MojoBootstrap> bootstrap_;
|
scoped_ptr<MojoBootstrap> bootstrap_;
|
||||||
base::WeakPtr<Delegate> delegate_;
|
base::WeakPtr<Delegate> delegate_;
|
||||||
|
@@ -30,7 +30,6 @@ class ChannelMojoHost::ChannelDelegate
|
|||||||
// ChannelMojo::Delegate
|
// ChannelMojo::Delegate
|
||||||
base::WeakPtr<Delegate> ToWeakPtr() override;
|
base::WeakPtr<Delegate> ToWeakPtr() override;
|
||||||
void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) override;
|
void OnChannelCreated(base::WeakPtr<ChannelMojo> channel) override;
|
||||||
scoped_refptr<base::TaskRunner> GetIOTaskRunner() override;
|
|
||||||
|
|
||||||
// Returns an weak ptr of ChannelDelegate instead of Delegate
|
// Returns an weak ptr of ChannelDelegate instead of Delegate
|
||||||
base::WeakPtr<ChannelDelegate> GetWeakPtr();
|
base::WeakPtr<ChannelDelegate> GetWeakPtr();
|
||||||
@@ -73,11 +72,6 @@ void ChannelMojoHost::ChannelDelegate::OnChannelCreated(
|
|||||||
channel_ = channel;
|
channel_ = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<base::TaskRunner>
|
|
||||||
ChannelMojoHost::ChannelDelegate::GetIOTaskRunner() {
|
|
||||||
return io_task_runner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelMojoHost::ChannelDelegate::OnClientLaunched(
|
void ChannelMojoHost::ChannelDelegate::OnClientLaunched(
|
||||||
base::ProcessHandle process) {
|
base::ProcessHandle process) {
|
||||||
if (channel_)
|
if (channel_)
|
||||||
|
@@ -66,12 +66,9 @@ class ListenerThatExpectsOK : public IPC::Listener {
|
|||||||
class ChannelClient {
|
class ChannelClient {
|
||||||
public:
|
public:
|
||||||
explicit ChannelClient(IPC::Listener* listener, const char* name) {
|
explicit ChannelClient(IPC::Listener* listener, const char* name) {
|
||||||
ipc_support_.reset(
|
channel_ = IPC::ChannelMojo::Create(NULL, main_message_loop_.task_runner(),
|
||||||
new IPC::ScopedIPCSupport(main_message_loop_.task_runner()));
|
|
||||||
channel_ = IPC::ChannelMojo::Create(NULL,
|
|
||||||
IPCTestBase::GetChannelName(name),
|
IPCTestBase::GetChannelName(name),
|
||||||
IPC::Channel::MODE_CLIENT,
|
IPC::Channel::MODE_CLIENT, listener);
|
||||||
listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connect() {
|
void Connect() {
|
||||||
@@ -90,7 +87,6 @@ class ChannelClient {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
base::MessageLoopForIO main_message_loop_;
|
base::MessageLoopForIO main_message_loop_;
|
||||||
scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
|
|
||||||
scoped_ptr<IPC::ChannelMojo> channel_;
|
scoped_ptr<IPC::ChannelMojo> channel_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,22 +94,17 @@ class IPCChannelMojoTestBase : public IPCTestBase {
|
|||||||
public:
|
public:
|
||||||
void InitWithMojo(const std::string& test_client_name) {
|
void InitWithMojo(const std::string& test_client_name) {
|
||||||
Init(test_client_name);
|
Init(test_client_name);
|
||||||
ipc_support_.reset(new IPC::ScopedIPCSupport(task_runner()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
// Make sure Mojo IPC support is properly shutdown on the I/O loop before
|
// Make sure Mojo IPC support is properly shutdown on the I/O loop before
|
||||||
// TearDown continues.
|
// TearDown continues.
|
||||||
ipc_support_.reset();
|
|
||||||
base::RunLoop run_loop;
|
base::RunLoop run_loop;
|
||||||
task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure());
|
task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure());
|
||||||
run_loop.Run();
|
run_loop.Run();
|
||||||
|
|
||||||
IPCTestBase::TearDown();
|
IPCTestBase::TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class IPCChannelMojoTest : public IPCChannelMojoTestBase {
|
class IPCChannelMojoTest : public IPCChannelMojoTestBase {
|
||||||
@@ -123,7 +114,7 @@ class IPCChannelMojoTest : public IPCChannelMojoTestBase {
|
|||||||
base::SequencedTaskRunner* runner) override {
|
base::SequencedTaskRunner* runner) override {
|
||||||
host_.reset(new IPC::ChannelMojoHost(task_runner()));
|
host_.reset(new IPC::ChannelMojoHost(task_runner()));
|
||||||
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
||||||
handle);
|
task_runner(), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DidStartClient() override {
|
bool DidStartClient() override {
|
||||||
@@ -231,7 +222,7 @@ class IPCChannelMojoErrorTest : public IPCChannelMojoTestBase {
|
|||||||
base::SequencedTaskRunner* runner) override {
|
base::SequencedTaskRunner* runner) override {
|
||||||
host_.reset(new IPC::ChannelMojoHost(task_runner()));
|
host_.reset(new IPC::ChannelMojoHost(task_runner()));
|
||||||
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
||||||
handle);
|
task_runner(), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DidStartClient() override {
|
bool DidStartClient() override {
|
||||||
@@ -565,7 +556,7 @@ class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase {
|
|||||||
base::SequencedTaskRunner* runner) override {
|
base::SequencedTaskRunner* runner) override {
|
||||||
host_.reset(new IPC::ChannelMojoHost(task_runner()));
|
host_.reset(new IPC::ChannelMojoHost(task_runner()));
|
||||||
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
||||||
handle);
|
task_runner(), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool DidStartClient() override {
|
virtual bool DidStartClient() override {
|
||||||
|
@@ -31,17 +31,15 @@ public:
|
|||||||
MojoChannelPerfTest();
|
MojoChannelPerfTest();
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
ipc_support_.reset();
|
|
||||||
IPC::test::IPCChannelPerfTestBase::TearDown();
|
IPC::test::IPCChannelPerfTestBase::TearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
|
scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
|
||||||
const IPC::ChannelHandle& handle,
|
const IPC::ChannelHandle& handle,
|
||||||
base::SequencedTaskRunner* runner) override {
|
base::SequencedTaskRunner* runner) override {
|
||||||
ipc_support_.reset(new IPC::ScopedIPCSupport(runner));
|
|
||||||
host_.reset(new IPC::ChannelMojoHost(runner));
|
host_.reset(new IPC::ChannelMojoHost(runner));
|
||||||
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
|
||||||
handle);
|
runner, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DidStartClient() override {
|
bool DidStartClient() override {
|
||||||
@@ -52,7 +50,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
|
|
||||||
scoped_ptr<IPC::ChannelMojoHost> host_;
|
scoped_ptr<IPC::ChannelMojoHost> host_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,9 +79,6 @@ class MojoTestClient : public IPC::test::PingPongTestClient {
|
|||||||
MojoTestClient();
|
MojoTestClient();
|
||||||
|
|
||||||
scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override;
|
scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override;
|
||||||
|
|
||||||
private:
|
|
||||||
scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MojoTestClient::MojoTestClient() {
|
MojoTestClient::MojoTestClient() {
|
||||||
@@ -93,12 +87,9 @@ MojoTestClient::MojoTestClient() {
|
|||||||
|
|
||||||
scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
|
scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
|
||||||
IPC::Listener* listener) {
|
IPC::Listener* listener) {
|
||||||
ipc_support_.reset(new IPC::ScopedIPCSupport(task_runner()));
|
return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create(
|
||||||
return scoped_ptr<IPC::Channel>(
|
NULL, task_runner(), IPCTestBase::GetChannelName("PerformanceClient"),
|
||||||
IPC::ChannelMojo::Create(NULL,
|
IPC::Channel::MODE_CLIENT, listener));
|
||||||
IPCTestBase::GetChannelName("PerformanceClient"),
|
|
||||||
IPC::Channel::MODE_CLIENT,
|
|
||||||
listener));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
|
MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
|
||||||
|
@@ -93,7 +93,8 @@ void ReplayProcess::OpenChannel() {
|
|||||||
content::ShouldUseMojoChannel();
|
content::ShouldUseMojoChannel();
|
||||||
if (should_use_mojo) {
|
if (should_use_mojo) {
|
||||||
channel_ = IPC::ChannelProxy::Create(
|
channel_ = IPC::ChannelProxy::Create(
|
||||||
IPC::ChannelMojo::CreateClientFactory(nullptr, channel_name), this,
|
IPC::ChannelMojo::CreateClientFactory(
|
||||||
|
nullptr, io_thread_.message_loop_proxy(), channel_name), this,
|
||||||
io_thread_.message_loop_proxy());
|
io_thread_.message_loop_proxy());
|
||||||
} else {
|
} else {
|
||||||
channel_ =
|
channel_ =
|
||||||
|
Reference in New Issue
Block a user