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

Unified Diff: content/renderer/mojo/mojo_render_process_observer.cc

Issue 195993010: Adds the ability for the renderer to create the mojo channel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use_mojo Created 6 years, 9 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/renderer/mojo/mojo_render_process_observer.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/mojo/mojo_render_process_observer.cc
diff --git a/content/renderer/mojo/mojo_render_process_observer.cc b/content/renderer/mojo/mojo_render_process_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f72e3989b9d4817010e7abbc072b1a01027cd274
--- /dev/null
+++ b/content/renderer/mojo/mojo_render_process_observer.cc
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/mojo/mojo_render_process_observer.h"
+
+#include "base/message_loop/message_loop.h"
+#include "content/child/child_process.h"
+#include "content/common/mojo/mojo_channel_init.h"
+#include "content/common/mojo/mojo_messages.h"
+#include "content/public/renderer/render_thread.h"
+
+namespace content {
+
+MojoRenderProcessObserver::MojoRenderProcessObserver(
+ RenderThread* render_thread)
+ : render_thread_(render_thread) {
+ render_thread_->AddObserver(this);
+}
+
+bool MojoRenderProcessObserver::OnControlMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(MojoRenderProcessObserver, message)
+ IPC_MESSAGE_HANDLER(MojoMsg_ChannelCreated, OnChannelCreated)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void MojoRenderProcessObserver::OnRenderProcessShutdown() {
+ delete this;
+}
+
+MojoRenderProcessObserver::~MojoRenderProcessObserver() {
+ render_thread_->RemoveObserver(this);
+}
+
+void MojoRenderProcessObserver::OnChannelCreated(
+ const IPC::PlatformFileForTransit& file) {
+#if defined(OS_POSIX)
+ base::PlatformFile handle = file.fd;
+#elif defined(OS_WIN)
+ base::PlatformFile handle = file;
+#endif
+ DCHECK(!channel_init_.get());
+ channel_init_.reset(new MojoChannelInit);
+ channel_init_->Init(handle, ChildProcess::current()->io_message_loop_proxy());
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/mojo/mojo_render_process_observer.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698