| 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/embedder_service_channel.h" |
| 6 | 6 |
| 7 #include "base/callback.h" |
| 7 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 8 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 9 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
| 10 #include "ipc/ipc_sync_channel.h" | 11 #include "ipc/ipc_sync_channel.h" |
| 11 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
| 12 | 13 |
| 13 namespace nacl { | 14 namespace nacl { |
| 14 | 15 |
| 15 TrustedPluginChannel::TrustedPluginChannel( | 16 EmbedderServiceChannel::EmbedderServiceChannel( |
| 16 const IPC::ChannelHandle& handle, | 17 const IPC::ChannelHandle& handle, |
| 17 const base::Callback<void(int32_t)>& connected_callback, | 18 const base::Callback<void(int32_t)>& connected_callback, |
| 18 base::WaitableEvent* waitable_event) | 19 base::WaitableEvent* waitable_event) |
| 19 : connected_callback_(connected_callback), | 20 : connected_callback_(connected_callback), |
| 20 channel_(new IPC::SyncChannel( | 21 channel_(new IPC::SyncChannel( |
| 21 handle, IPC::Channel::MODE_CLIENT, this, | 22 handle, IPC::Channel::MODE_CLIENT, this, |
| 22 content::RenderThread::Get()->GetIOMessageLoopProxy(), true, | 23 content::RenderThread::Get()->GetIOMessageLoopProxy(), |
| 23 waitable_event)) { | 24 true, waitable_event)) { |
| 24 } | 25 } |
| 25 | 26 |
| 26 TrustedPluginChannel::~TrustedPluginChannel() { | 27 EmbedderServiceChannel::~EmbedderServiceChannel() { |
| 27 if (!connected_callback_.is_null()) | 28 if (!connected_callback_.is_null()) |
| 28 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); | 29 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); |
| 29 } | 30 } |
| 30 | 31 |
| 31 bool TrustedPluginChannel::Send(IPC::Message* message) { | 32 bool EmbedderServiceChannel::OnMessageReceived(const IPC::Message& message) { |
| 32 return channel_->Send(message); | 33 // TODO(hidehiko): Impelement StartCompleted and OpenResource. |
| 33 } | |
| 34 | |
| 35 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& message) { | |
| 36 return false; | 34 return false; |
| 37 } | 35 } |
| 38 | 36 |
| 39 void TrustedPluginChannel::OnChannelConnected(int32 peer_pid) { | 37 void EmbedderServiceChannel::OnChannelConnected(int32 peer_pid) { |
| 40 if (!connected_callback_.is_null()) | 38 if (!connected_callback_.is_null()) |
| 41 base::ResetAndReturn(&connected_callback_).Run(PP_OK); | 39 base::ResetAndReturn(&connected_callback_).Run(PP_OK); |
| 42 } | 40 } |
| 43 | 41 |
| 44 void TrustedPluginChannel::OnChannelError() { | 42 void EmbedderServiceChannel::OnChannelError() { |
| 45 if (!connected_callback_.is_null()) | 43 if (!connected_callback_.is_null()) |
| 46 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); | 44 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); |
| 47 } | 45 } |
| 48 | 46 |
| 49 } // namespace nacl | 47 } // namespace nacl |
| OLD | NEW |