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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ipc/ipc_platform_file.h" | 8 #include "ipc/ipc_platform_file.h" |
9 #include "ipc/ipc_test_sink.h" | 9 #include "ipc/ipc_test_sink.h" |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 return channel()->TakeClientFileDescriptor(); | 57 return channel()->TakeClientFileDescriptor(); |
58 } | 58 } |
59 #endif | 59 #endif |
60 | 60 |
61 IPC::PlatformFileForTransit ProxyChannel::ShareHandleWithRemote( | 61 IPC::PlatformFileForTransit ProxyChannel::ShareHandleWithRemote( |
62 base::PlatformFile handle, | 62 base::PlatformFile handle, |
63 bool should_close_source) { | 63 bool should_close_source) { |
64 // Channel could be closed if the plugin crashes. | 64 // Channel could be closed if the plugin crashes. |
65 if (!channel_.get()) { | 65 if (!channel_.get()) { |
66 if (should_close_source) { | 66 if (should_close_source) { |
67 #if !defined(OS_NACL) | 67 base::File file_closer(handle); |
68 base::ClosePlatformFile(handle); | |
69 #else | |
70 close(handle); | |
71 #endif | |
72 } | 68 } |
73 return IPC::InvalidPlatformFileForTransit(); | 69 return IPC::InvalidPlatformFileForTransit(); |
74 } | 70 } |
75 DCHECK(peer_pid_ != base::kNullProcessId); | 71 DCHECK(peer_pid_ != base::kNullProcessId); |
76 return delegate_->ShareHandleWithRemote(handle, peer_pid_, | 72 return delegate_->ShareHandleWithRemote(handle, peer_pid_, |
77 should_close_source); | 73 should_close_source); |
78 } | 74 } |
79 | 75 |
80 bool ProxyChannel::Send(IPC::Message* msg) { | 76 bool ProxyChannel::Send(IPC::Message* msg) { |
81 if (test_sink_) | 77 if (test_sink_) |
82 return test_sink_->Send(msg); | 78 return test_sink_->Send(msg); |
83 if (channel_.get()) | 79 if (channel_.get()) |
84 return channel_->Send(msg); | 80 return channel_->Send(msg); |
85 | 81 |
86 // Remote side crashed, drop this message. | 82 // Remote side crashed, drop this message. |
87 delete msg; | 83 delete msg; |
88 return false; | 84 return false; |
89 } | 85 } |
90 | 86 |
91 } // namespace proxy | 87 } // namespace proxy |
92 } // namespace ppapi | 88 } // namespace ppapi |
OLD | NEW |