| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/proxy_channel.h" | 5 #include "ppapi/proxy/proxy_channel.h" |
| 6 | 6 |
| 7 #include "ipc/ipc_platform_file.h" | 7 #include "ipc/ipc_platform_file.h" |
| 8 #include "ipc/ipc_test_sink.h" | 8 #include "ipc/ipc_test_sink.h" |
| 9 | 9 |
| 10 #if defined(OS_NACL) |
| 11 #include <unistd.h> |
| 12 #endif |
| 13 |
| 10 namespace ppapi { | 14 namespace ppapi { |
| 11 namespace proxy { | 15 namespace proxy { |
| 12 | 16 |
| 13 ProxyChannel::ProxyChannel() | 17 ProxyChannel::ProxyChannel() |
| 14 : delegate_(NULL), | 18 : delegate_(NULL), |
| 15 test_sink_(NULL) { | 19 test_sink_(NULL) { |
| 16 } | 20 } |
| 17 | 21 |
| 18 ProxyChannel::~ProxyChannel() { | 22 ProxyChannel::~ProxyChannel() { |
| 19 DVLOG(1) << "ProxyChannel::~ProxyChannel()"; | 23 DVLOG(1) << "ProxyChannel::~ProxyChannel()"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 44 int ProxyChannel::TakeRendererFD() { | 48 int ProxyChannel::TakeRendererFD() { |
| 45 DCHECK(channel()); | 49 DCHECK(channel()); |
| 46 return channel()->TakeClientFileDescriptor(); | 50 return channel()->TakeClientFileDescriptor(); |
| 47 } | 51 } |
| 48 #endif | 52 #endif |
| 49 | 53 |
| 50 IPC::PlatformFileForTransit ProxyChannel::ShareHandleWithRemote( | 54 IPC::PlatformFileForTransit ProxyChannel::ShareHandleWithRemote( |
| 51 base::PlatformFile handle, | 55 base::PlatformFile handle, |
| 52 bool should_close_source) { | 56 bool should_close_source) { |
| 53 // Channel could be closed if the plugin crashes. | 57 // Channel could be closed if the plugin crashes. |
| 54 if (!channel_.get()) | 58 if (!channel_.get()) { |
| 59 if (should_close_source) { |
| 60 #if !defined(OS_NACL) |
| 61 base::ClosePlatformFile(handle); |
| 62 #else |
| 63 close(handle); |
| 64 #endif |
| 65 } |
| 55 return IPC::InvalidPlatformFileForTransit(); | 66 return IPC::InvalidPlatformFileForTransit(); |
| 67 } |
| 56 return delegate_->ShareHandleWithRemote(handle, *channel_, | 68 return delegate_->ShareHandleWithRemote(handle, *channel_, |
| 57 should_close_source); | 69 should_close_source); |
| 58 } | 70 } |
| 59 | 71 |
| 60 bool ProxyChannel::Send(IPC::Message* msg) { | 72 bool ProxyChannel::Send(IPC::Message* msg) { |
| 61 if (test_sink_) | 73 if (test_sink_) |
| 62 return test_sink_->Send(msg); | 74 return test_sink_->Send(msg); |
| 63 if (channel_.get()) | 75 if (channel_.get()) |
| 64 return channel_->Send(msg); | 76 return channel_->Send(msg); |
| 65 | 77 |
| 66 // Remote side crashed, drop this message. | 78 // Remote side crashed, drop this message. |
| 67 delete msg; | 79 delete msg; |
| 68 return false; | 80 return false; |
| 69 } | 81 } |
| 70 | 82 |
| 71 } // namespace proxy | 83 } // namespace proxy |
| 72 } // namespace ppapi | 84 } // namespace ppapi |
| OLD | NEW |