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

Unified Diff: content/child/child_thread.cc

Issue 382333002: Introduce ChannelMojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed ChanelBuilder to ChannelFactory Created 6 years, 5 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 315224e79d8f212401804d811c7645266e47d4bd..13e1397e2c32e7c19541093d235bae17071de7f6 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"
@@ -204,20 +205,46 @@ ChildThread::ChildThread()
: router_(this),
channel_connected_factory_(this),
in_browser_process_(false) {
- channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ InitOptions options;
+ options.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 InitOptions& options)
+ : router_(this),
channel_connected_factory_(this),
in_browser_process_(true) {
- Init();
+ Init(options);
+}
+
+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());
+ } else {
darin (slow to review) 2014/07/23 23:03:33 nit: no need for "else" after "return"
Hajime Morrita 2014/07/24 00:38:44 Done.
+ 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() {
+void ChildThread::Init(const InitOptions& options) {
+ channel_name_ = options.channel_name;
+
g_lazy_tls.Pointer()->Set(this);
on_channel_error_called_ = false;
message_loop_ = base::MessageLoop::current();
@@ -227,13 +254,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);

Powered by Google App Engine
This is Rietveld 408576698