Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / nacl / renderer / trusted_plugin_channel.cc
blob0aaf6bc34c29991034a731f2bdc8852c5a16d6cb
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.
5 #include "components/nacl/renderer/trusted_plugin_channel.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"
10 #include "content/public/renderer/render_thread.h"
11 #include "ipc/ipc_sync_channel.h"
12 #include "ipc/ipc_message_macros.h"
13 #include "ppapi/c/pp_errors.h"
15 namespace nacl {
17 TrustedPluginChannel::TrustedPluginChannel(
18 NexeLoadManager* nexe_load_manager,
19 const IPC::ChannelHandle& handle,
20 base::WaitableEvent* shutdown_event,
21 bool report_exit_status)
22 : nexe_load_manager_(nexe_load_manager),
23 report_exit_status_(report_exit_status) {
24 channel_ = IPC::SyncChannel::Create(
25 handle,
26 IPC::Channel::MODE_CLIENT,
27 this,
28 content::RenderThread::Get()->GetIOMessageLoopProxy(),
29 true,
30 shutdown_event).Pass();
33 TrustedPluginChannel::~TrustedPluginChannel() {
36 bool TrustedPluginChannel::Send(IPC::Message* message) {
37 return channel_->Send(message);
40 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& msg) {
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;
49 void TrustedPluginChannel::OnReportExitStatus(int exit_status) {
50 if (report_exit_status_)
51 nexe_load_manager_->set_exit_status(exit_status);
54 } // namespace nacl