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

Unified Diff: content/child/child_thread.cc

Issue 382333002: Introduce ChannelMojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: content/child/child_thread.cc
diff --git a/content/child/child_thread.cc b/content/child/child_thread.cc
index b153f044f103e350950e44dad61637e71d4940fa..7e58c1ffd2fd449b193d5829d5de424279f7bd0d 100644
--- a/content/child/child_thread.cc
+++ b/content/child/child_thread.cc
@@ -48,6 +48,7 @@
#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"
#if defined(OS_WIN)
#include "content/common/handle_enumerator_win.h"
@@ -192,6 +193,17 @@ void QuitMainThreadMessageLoop() {
} // namespace
+ChildThread::Options::Options()
+ : channel_name(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProcessChannelID)),
+ use_mojo_channel(false) {}
+
+ChildThread::Options::Options(bool mojo)
+ : channel_name(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProcessChannelID)),
+ use_mojo_channel(mojo) {}
+
+
ChildThread::ChildThreadMessageRouter::ChildThreadMessageRouter(
IPC::Sender* sender)
: sender_(sender) {}
@@ -204,20 +216,43 @@ ChildThread::ChildThread()
: router_(this),
channel_connected_factory_(this),
in_browser_process_(false) {
- channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kProcessChannelID);
- Init();
+ Init(Options());
}
-ChildThread::ChildThread(const std::string& channel_name)
- : channel_name_(channel_name),
- router_(this),
+ChildThread::ChildThread(const Options& options)
+ : router_(this),
channel_connected_factory_(this),
in_browser_process_(true) {
- Init();
+ Init(options);
}
-void ChildThread::Init() {
+scoped_ptr<IPC::SyncChannel> ChildThread::CreateChannel(bool use_mojo_channel) {
+ if (use_mojo_channel) {
+ VLOG(1) << "Mojo is enabled on child";
+ return IPC::SyncChannel::Create(
+ IPC::ChannelMojo::CreateFactory(
+ channel_name_,
+ IPC::Channel::MODE_CLIENT,
+ ChildProcess::current()->io_message_loop_proxy()),
+ this,
+ ChildProcess::current()->io_message_loop_proxy(),
+ true,
+ ChildProcess::current()->GetShutDownEvent());
+ }
+
+ VLOG(1) << "Mojo is disabled on child";
+ return IPC::SyncChannel::Create(
+ channel_name_,
+ IPC::Channel::MODE_CLIENT,
+ this,
+ ChildProcess::current()->io_message_loop_proxy(),
+ true,
+ ChildProcess::current()->GetShutDownEvent());
+}
+
+void ChildThread::Init(const Options& options) {
+ channel_name_ = options.channel_name;
+
g_lazy_tls.Pointer()->Set(this);
on_channel_error_called_ = false;
message_loop_ = base::MessageLoop::current();
@@ -227,13 +262,7 @@ void ChildThread::Init() {
// the logger, and the logger does not like being created on the IO thread.
IPC::Logging::GetInstance();
#endif
- channel_ =
- IPC::SyncChannel::Create(channel_name_,
- IPC::Channel::MODE_CLIENT,
- this,
- ChildProcess::current()->io_message_loop_proxy(),
- true,
- ChildProcess::current()->GetShutDownEvent());
+ channel_ = CreateChannel(options.use_mojo_channel);
#ifdef IPC_MESSAGE_LOG_ENABLED
if (!in_browser_process_)
IPC::Logging::GetInstance()->SetIPCSender(this);
« no previous file with comments | « content/child/child_thread.h ('k') | content/common/BUILD.gn » ('j') | ipc/ipc_channel.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698