OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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 "components/nacl/renderer/trusted_plugin_channel.h" |
| 6 |
| 7 #include "base/debug/stack_trace.h" |
| 8 #include "content/public/renderer/render_thread.h" |
| 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/cpp/completion_callback.h" |
| 11 #include "ppapi/cpp/module.h" |
| 12 #include "ppapi/shared_impl/ppapi_globals.h" |
| 13 |
| 14 namespace nacl { |
| 15 |
| 16 TrustedPluginChannel::TrustedPluginChannel( |
| 17 const IPC::ChannelHandle& handle, |
| 18 PP_CompletionCallback connected_callback) |
| 19 : connected_callback_(connected_callback), |
| 20 shutdown_event_(true, false) { |
| 21 fprintf(stderr, "TrustedPluginChannel::TrustedPluginChannel"); |
| 22 fprintf(stderr, "fd: %d\n", handle.socket.fd); |
| 23 fprintf(stderr, "message_loop: %p\n", base::MessageLoop::current()); |
| 24 channel_.reset(new IPC::SyncChannel( |
| 25 handle, IPC::Channel::MODE_CLIENT, this, |
| 26 content::RenderThread::Get()->GetIOMessageLoopProxy(), true, |
| 27 &shutdown_event_)); |
| 28 } |
| 29 |
| 30 bool TrustedPluginChannel::Send(IPC::Message* message) { |
| 31 fprintf(stderr, "TrustedPluginChannel::Send(), message=%p\n", message); |
| 32 return channel_->Send(message); |
| 33 } |
| 34 |
| 35 bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& message) { |
| 36 return false; |
| 37 } |
| 38 |
| 39 void TrustedPluginChannel::OnChannelConnected(int32 peer_pid) { |
| 40 fprintf(stderr, "TrustedPluginChannel::OnChannelConnected, peer_pid=%d\n", |
| 41 peer_pid); |
| 42 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 43 FROM_HERE, |
| 44 base::Bind(connected_callback_.func, |
| 45 connected_callback_.user_data, |
| 46 static_cast<int32_t>(PP_OK))); |
| 47 connected_callback_ = PP_BlockUntilComplete(); |
| 48 } |
| 49 |
| 50 void TrustedPluginChannel::OnChannelError() { |
| 51 fprintf(stderr, "TrustedPluginChannel::OnChannelError\n"); |
| 52 if (connected_callback_.func) { |
| 53 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 54 FROM_HERE, |
| 55 base::Bind(connected_callback_.func, |
| 56 connected_callback_.user_data, |
| 57 static_cast<int32_t>(PP_ERROR_FAILED))); |
| 58 connected_callback_ = PP_BlockUntilComplete(); |
| 59 } |
| 60 } |
| 61 |
| 62 } // namespace nacl |
OLD | NEW |