| 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_message_filter.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 MojoMessageFilter::MojoMessageFilter(RenderThread* render_thread) |
| 16 : render_thread_(render_thread) { |
| 17 render_thread_->AddObserver(this); |
| 18 } |
| 19 |
| 20 bool MojoMessageFilter::OnControlMessageReceived(const IPC::Message& message) { |
| 21 bool handled = true; |
| 22 IPC_BEGIN_MESSAGE_MAP(MojoMessageFilter, message) |
| 23 IPC_MESSAGE_HANDLER(MojoMsg_ChannelCreated, OnChannelCreated) |
| 24 IPC_MESSAGE_UNHANDLED(handled = false) |
| 25 IPC_END_MESSAGE_MAP() |
| 26 return handled; |
| 27 } |
| 28 |
| 29 void MojoMessageFilter::OnRenderProcessShutdown() { |
| 30 delete this; |
| 31 } |
| 32 |
| 33 MojoMessageFilter::~MojoMessageFilter() { |
| 34 render_thread_->RemoveObserver(this); |
| 35 } |
| 36 |
| 37 void MojoMessageFilter::OnChannelCreated( |
| 38 const IPC::PlatformFileForTransit& file) { |
| 39 #if defined(OS_POSIX) |
| 40 base::PlatformFile handle = file.fd; |
| 41 #elif defined(OS_WIN) |
| 42 base::PlatformFile handle = file; |
| 43 #endif |
| 44 DCHECK(!channel_init_.get()); |
| 45 channel_init_.reset(new MojoChannelInit); |
| 46 channel_init_->Init(handle, |
| 47 ChildProcess::current()->current()->io_message_loop_proxy()); |
| 48 } |
| 49 |
| 50 } // namespace content |
| OLD | NEW |