| 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 "base/strings/string_tokenizer.h" |
| 9 #include "components/nacl/common/nacl_messages.h" |
| 8 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| 9 #include "ipc/ipc_channel_proxy.h" | 11 #include "ipc/ipc_channel_proxy.h" |
| 12 #include "ipc/ipc_message_macros.h" |
| 10 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
| 14 #include "ppapi/shared_impl/ppapi_globals.h" |
| 11 | 15 |
| 12 namespace nacl { | 16 namespace nacl { |
| 13 | 17 |
| 14 TrustedPluginChannel::TrustedPluginChannel( | 18 TrustedPluginChannel::TrustedPluginChannel( |
| 15 const IPC::ChannelHandle& handle) { | 19 PP_Instance instance, |
| 20 const IPC::ChannelHandle& handle) |
| 21 : instance_(instance) { |
| 16 channel_proxy_ = IPC::ChannelProxy::Create( | 22 channel_proxy_ = IPC::ChannelProxy::Create( |
| 17 handle, | 23 handle, |
| 18 IPC::Channel::MODE_CLIENT, | 24 IPC::Channel::MODE_CLIENT, |
| 19 this, | 25 this, |
| 20 content::RenderThread::Get()->GetIOMessageLoopProxy()).Pass(); | 26 content::RenderThread::Get()->GetIOMessageLoopProxy()).Pass(); |
| 21 } | 27 } |
| 22 | 28 |
| 23 TrustedPluginChannel::~TrustedPluginChannel() { | 29 TrustedPluginChannel::~TrustedPluginChannel() { |
| 24 } | 30 } |
| 25 | 31 |
| 26 bool TrustedPluginChannel::Send(IPC::Message* message) { | 32 bool TrustedPluginChannel::Send(IPC::Message* message) { |
| 27 return channel_proxy_->Send(message); | 33 return channel_proxy_->Send(message); |
| 28 } | 34 } |
| 29 | 35 |
| 30 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& message) { | 36 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& message) { |
| 31 return false; | 37 bool handled = true; |
| 38 IPC_BEGIN_MESSAGE_MAP(TrustedPluginChannel, message) |
| 39 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_FatalLogReceived, |
| 40 OnFatalLogReceived) |
| 41 IPC_MESSAGE_UNHANDLED(handled = false) |
| 42 IPC_END_MESSAGE_MAP() |
| 43 return handled; |
| 44 } |
| 45 |
| 46 void TrustedPluginChannel::OnFatalLogReceived(const std::string& fatal_log) { |
| 47 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
| 48 BelongsToCurrentThread()); |
| 49 |
| 50 base::StringTokenizer t(fatal_log, "\n"); |
| 51 while (t.GetNext()) { |
| 52 ppapi::PpapiGlobals::Get()->LogWithSource( |
| 53 instance_, PP_LOGLEVEL_LOG, std::string("NativeClient"), t.token()); |
| 54 } |
| 32 } | 55 } |
| 33 | 56 |
| 34 } // namespace nacl | 57 } // namespace nacl |
| OLD | NEW |