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

Unified Diff: content/child/child_thread_impl.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 | « content/child/child_thread_impl.h ('k') | content/test/render_thread_impl_browser_test_ipc_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/child_thread_impl.cc
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc
index 685fded9b0544f075196d5d6b3c2448775452f26..013d1d51302d1920edcbe76ec7b463357789c8f5 100644
--- a/content/child/child_thread_impl.cc
+++ b/content/child/child_thread_impl.cc
@@ -56,6 +56,7 @@
#include "ipc/ipc_sync_channel.h"
#include "ipc/ipc_sync_message_filter.h"
#include "ipc/mojo/ipc_channel_mojo.h"
+#include "ipc/mojo/scoped_ipc_support.h"
#if defined(OS_WIN)
#include "content/common/handle_enumerator_win.h"
@@ -204,6 +205,45 @@
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()
: channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessChannelID)),
@@ -281,9 +321,15 @@
VLOG(1) << "Mojo is enabled on child";
scoped_refptr<base::SequencedTaskRunner> io_task_runner = GetIOTaskRunner();
DCHECK(io_task_runner);
- channel_->Init(IPC::ChannelMojo::CreateClientFactory(
- nullptr, io_task_runner, channel_name_),
- create_pipe_now);
+ if (IsInBrowserProcess())
+ single_process_channel_delegate_.reset(
+ new SingleProcessChannelDelegate(io_task_runner));
+ 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;
}
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/test/render_thread_impl_browser_test_ipc_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698