| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/nacl/renderer/trusted_plugin_channel.h" | 5 #include "components/nacl/renderer/trusted_plugin_channel.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "components/nacl/common/nacl_renderer_messages.h" |
| 9 #include "components/nacl/renderer/nexe_load_manager.h" |
| 8 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| 9 #include "ipc/ipc_sync_channel.h" | 11 #include "ipc/ipc_sync_channel.h" |
| 12 #include "ipc/ipc_message_macros.h" |
| 10 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
| 11 | 14 |
| 12 namespace nacl { | 15 namespace nacl { |
| 13 | 16 |
| 14 TrustedPluginChannel::TrustedPluginChannel( | 17 TrustedPluginChannel::TrustedPluginChannel( |
| 18 NexeLoadManager* nexe_load_manager, |
| 15 const IPC::ChannelHandle& handle, | 19 const IPC::ChannelHandle& handle, |
| 16 base::WaitableEvent* shutdown_event) { | 20 base::WaitableEvent* shutdown_event, |
| 21 bool report_exit_status) |
| 22 : nexe_load_manager_(nexe_load_manager), |
| 23 report_exit_status_(report_exit_status) { |
| 17 channel_ = IPC::SyncChannel::Create( | 24 channel_ = IPC::SyncChannel::Create( |
| 18 handle, | 25 handle, |
| 19 IPC::Channel::MODE_CLIENT, | 26 IPC::Channel::MODE_CLIENT, |
| 20 this, | 27 this, |
| 21 content::RenderThread::Get()->GetIOMessageLoopProxy(), | 28 content::RenderThread::Get()->GetIOMessageLoopProxy(), |
| 22 true, | 29 true, |
| 23 shutdown_event).Pass(); | 30 shutdown_event).Pass(); |
| 24 } | 31 } |
| 25 | 32 |
| 26 TrustedPluginChannel::~TrustedPluginChannel() { | 33 TrustedPluginChannel::~TrustedPluginChannel() { |
| 27 } | 34 } |
| 28 | 35 |
| 29 bool TrustedPluginChannel::Send(IPC::Message* message) { | 36 bool TrustedPluginChannel::Send(IPC::Message* message) { |
| 30 return channel_->Send(message); | 37 return channel_->Send(message); |
| 31 } | 38 } |
| 32 | 39 |
| 33 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& message) { | 40 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& msg) { |
| 34 return false; | 41 bool handled = true; |
| 42 IPC_BEGIN_MESSAGE_MAP(TrustedPluginChannel, msg) |
| 43 IPC_MESSAGE_HANDLER(NaClRendererMsg_ReportExitStatus, OnReportExitStatus); |
| 44 IPC_MESSAGE_UNHANDLED(handled = false); |
| 45 IPC_END_MESSAGE_MAP() |
| 46 return handled; |
| 47 } |
| 48 |
| 49 void TrustedPluginChannel::OnReportExitStatus(int exit_status) { |
| 50 if (report_exit_status_) |
| 51 nexe_load_manager_->set_exit_status(exit_status); |
| 35 } | 52 } |
| 36 | 53 |
| 37 } // namespace nacl | 54 } // namespace nacl |
| OLD | NEW |