| 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 "content/renderer/pepper/pepper_broker.h" | 5 #include "content/renderer/pepper/pepper_broker.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" | 8 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" |
| 9 #include "content/renderer/pepper/plugin_module.h" | 9 #include "content/renderer/pepper/plugin_module.h" |
| 10 #include "content/renderer/pepper/ppb_broker_impl.h" | 10 #include "content/renderer/pepper/ppb_broker_impl.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Does not take ownership of the local pipe. | 82 // Does not take ownership of the local pipe. |
| 83 int32_t PepperBrokerDispatcherWrapper::SendHandleToBroker( | 83 int32_t PepperBrokerDispatcherWrapper::SendHandleToBroker( |
| 84 PP_Instance instance, | 84 PP_Instance instance, |
| 85 base::SyncSocket::Handle handle) { | 85 base::SyncSocket::Handle handle) { |
| 86 IPC::PlatformFileForTransit foreign_socket_handle = | 86 IPC::PlatformFileForTransit foreign_socket_handle = |
| 87 dispatcher_->ShareHandleWithRemote(handle, false); | 87 dispatcher_->ShareHandleWithRemote(handle, false); |
| 88 if (foreign_socket_handle == IPC::InvalidPlatformFileForTransit()) | 88 if (foreign_socket_handle == IPC::InvalidPlatformFileForTransit()) |
| 89 return PP_ERROR_FAILED; | 89 return PP_ERROR_FAILED; |
| 90 | 90 |
| 91 int32_t result; | 91 int32_t result = PP_ERROR_FAILED; |
| 92 if (!dispatcher_->Send(new PpapiMsg_ConnectToPlugin( | 92 if (!dispatcher_->Send(new PpapiMsg_ConnectToPlugin( |
| 93 instance, foreign_socket_handle, &result))) { | 93 instance, foreign_socket_handle, &result))) { |
| 94 // The plugin did not receive the handle, so it must be closed. | 94 // The plugin did not receive the handle, so it must be closed. |
| 95 // The easiest way to clean it up is to just put it in an object | 95 // The easiest way to clean it up is to just put it in an object |
| 96 // and then close it. This failure case is not performance critical. | 96 // and then close it. This failure case is not performance critical. |
| 97 // The handle could still leak if Send succeeded but the IPC later failed. | 97 // The handle could still leak if Send succeeded but the IPC later failed. |
| 98 base::SyncSocket temp_socket( | 98 base::SyncSocket temp_socket( |
| 99 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle)); | 99 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle)); |
| 100 return PP_ERROR_FAILED; | 100 return PP_ERROR_FAILED; |
| 101 } | 101 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing | 248 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing |
| 249 // client and plugin_socket.release(), then return. | 249 // client and plugin_socket.release(), then return. |
| 250 // That message handler will then call client->BrokerConnected() with the | 250 // That message handler will then call client->BrokerConnected() with the |
| 251 // saved pipe handle. | 251 // saved pipe handle. |
| 252 // Temporarily, just call back. | 252 // Temporarily, just call back. |
| 253 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); | 253 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); |
| 254 } | 254 } |
| 255 | 255 |
| 256 } // namespace content | 256 } // namespace content |
| OLD | NEW |