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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/mojo/mojo_render_process_observer.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "content/child/child_process.h"
9 #include "content/common/mojo/mojo_channel_init.h"
10 #include "content/common/mojo/mojo_messages.h"
11 #include "content/public/renderer/render_thread.h"
12
13 namespace content {
14
15 MojoRenderProcessObserver::MojoRenderProcessObserver(
16 RenderThread* render_thread)
17 : render_thread_(render_thread) {
18 render_thread_->AddObserver(this);
19 }
20
21 bool MojoRenderProcessObserver::OnControlMessageReceived(
22 const IPC::Message& message) {
23 bool handled = true;
24 IPC_BEGIN_MESSAGE_MAP(MojoRenderProcessObserver, message)
25 IPC_MESSAGE_HANDLER(MojoMsg_ChannelCreated, OnChannelCreated)
26 IPC_MESSAGE_UNHANDLED(handled = false)
27 IPC_END_MESSAGE_MAP()
28 return handled;
29 }
30
31 void MojoRenderProcessObserver::OnRenderProcessShutdown() {
32 delete this;
33 }
34
35 MojoRenderProcessObserver::~MojoRenderProcessObserver() {
36 render_thread_->RemoveObserver(this);
37 }
38
39 void MojoRenderProcessObserver::OnChannelCreated(
40 const IPC::PlatformFileForTransit& file) {
41 #if defined(OS_POSIX)
42 base::PlatformFile handle = file.fd;
43 #elif defined(OS_WIN)
44 base::PlatformFile handle = file;
45 #endif
46 DCHECK(!channel_init_.get());
47 channel_init_.reset(new MojoChannelInit);
48 channel_init_->Init(handle, ChildProcess::current()->io_message_loop_proxy());
49 }
50
51 } // namespace content
OLDNEW
« 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