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

Unified Diff: content/child/child_thread_impl.cc

Issue 954643002: Update mojo sdk to rev 3d23dae011859a2aae49f1d1adde705c8e85d819 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use run_renderer_in_process() Created 5 years, 10 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/child/mojo/mojo_application.h » ('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 5df66318d42a5cc76c8f9307976153f4f4f72691..8acc37dfcf806a277fdd39804538e4615180a561 100644
--- a/content/child/child_thread_impl.cc
+++ b/content/child/child_thread_impl.cc
@@ -49,12 +49,14 @@
#include "content/child/thread_safe_sender.h"
#include "content/child/websocket_dispatcher.h"
#include "content/common/child_process_messages.h"
+#include "content/common/mojo/channel_init.h"
#include "content/public/common/content_switches.h"
#include "ipc/ipc_logging.h"
#include "ipc/ipc_switches.h"
#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"
@@ -203,6 +205,42 @@ ChildThread* ChildThread::Get() {
return ChildThreadImpl::current();
}
+// Mojo client channel delegate to be used in single process mode.
+class ChildThreadImpl::SingleProcessChannelDelegate
+ : public IPC::ChannelMojo::Delegate {
+ public:
+ explicit SingleProcessChannelDelegate() : weak_factory_(this) {}
+
+ ~SingleProcessChannelDelegate() override {}
+
+ base::WeakPtr<IPC::ChannelMojo::Delegate> ToWeakPtr() override {
+ return weak_factory_.GetWeakPtr();
+ }
+
+ scoped_refptr<base::TaskRunner> GetIOTaskRunner() override {
+ return ChannelInit::GetSingleProcessIOTaskRunner();
+ }
+
+ void OnChannelCreated(base::WeakPtr<IPC::ChannelMojo> channel) override {}
+
+ void DeleteSoon() {
+ ChannelInit::GetSingleProcessIOTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&base::DeletePointer<SingleProcessChannelDelegate>,
+ base::Unretained(this)));
+ }
+
+ private:
+ 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)),
@@ -250,8 +288,20 @@ void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) {
bool create_pipe_now = true;
if (use_mojo_channel) {
VLOG(1) << "Mojo is enabled on child";
- channel_->Init(IPC::ChannelMojo::CreateClientFactory(channel_name_),
- create_pipe_now);
+ scoped_refptr<base::TaskRunner> io_task_runner =
+ ChannelInit::GetSingleProcessIOTaskRunner();
+ if (io_task_runner) {
+ single_process_channel_delegate_.reset(new SingleProcessChannelDelegate);
+ } else {
+ io_task_runner = ChildProcess::current()->io_message_loop_proxy();
+ }
+ DCHECK(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/child/mojo/mojo_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698