OLD | NEW |
(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 |
OLD | NEW |