| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // TODO(ddorwin): Send message disconnect message using dispatcher_. | 141 // TODO(ddorwin): Send message disconnect message using dispatcher_. |
| 142 | 142 |
| 143 // Release the reference added in Connect(). | 143 // Release the reference added in Connect(). |
| 144 // This must be the last statement because it may delete this object. | 144 // This must be the last statement because it may delete this object. |
| 145 Release(); | 145 Release(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void PepperBroker::OnBrokerChannelConnected( | 148 void PepperBroker::OnBrokerChannelConnected( |
| 149 base::ProcessId broker_pid, | 149 base::ProcessId broker_pid, |
| 150 const IPC::ChannelHandle& channel_handle) { | 150 const IPC::ChannelHandle& channel_handle) { |
| 151 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher( | 151 std::unique_ptr<PepperBrokerDispatcherWrapper> dispatcher( |
| 152 new PepperBrokerDispatcherWrapper); | 152 new PepperBrokerDispatcherWrapper); |
| 153 if (!dispatcher->Init(broker_pid, channel_handle)) { | 153 if (!dispatcher->Init(broker_pid, channel_handle)) { |
| 154 ReportFailureToClients(PP_ERROR_FAILED); | 154 ReportFailureToClients(PP_ERROR_FAILED); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 | 157 |
| 158 dispatcher_.reset(dispatcher.release()); | 158 dispatcher_.reset(dispatcher.release()); |
| 159 | 159 |
| 160 // Process all pending channel requests from the plugins. | 160 // Process all pending channel requests from the plugins. |
| 161 for (ClientMap::iterator i = pending_connects_.begin(); | 161 for (ClientMap::iterator i = pending_connects_.begin(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 227 } |
| 228 pending_connects_.clear(); | 228 pending_connects_.clear(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void PepperBroker::ConnectPluginToBroker(PPB_Broker_Impl* client) { | 231 void PepperBroker::ConnectPluginToBroker(PPB_Broker_Impl* client) { |
| 232 base::SyncSocket::Handle plugin_handle = base::SyncSocket::kInvalidHandle; | 232 base::SyncSocket::Handle plugin_handle = base::SyncSocket::kInvalidHandle; |
| 233 int32_t result = PP_OK; | 233 int32_t result = PP_OK; |
| 234 | 234 |
| 235 // The socket objects will be deleted when this function exits, closing the | 235 // The socket objects will be deleted when this function exits, closing the |
| 236 // handles. Any uses of the socket must duplicate them. | 236 // handles. Any uses of the socket must duplicate them. |
| 237 scoped_ptr<base::SyncSocket> broker_socket(new base::SyncSocket()); | 237 std::unique_ptr<base::SyncSocket> broker_socket(new base::SyncSocket()); |
| 238 scoped_ptr<base::SyncSocket> plugin_socket(new base::SyncSocket()); | 238 std::unique_ptr<base::SyncSocket> plugin_socket(new base::SyncSocket()); |
| 239 if (base::SyncSocket::CreatePair(broker_socket.get(), plugin_socket.get())) { | 239 if (base::SyncSocket::CreatePair(broker_socket.get(), plugin_socket.get())) { |
| 240 result = dispatcher_->SendHandleToBroker(client->pp_instance(), | 240 result = dispatcher_->SendHandleToBroker(client->pp_instance(), |
| 241 broker_socket->handle()); | 241 broker_socket->handle()); |
| 242 | 242 |
| 243 // If the broker has its pipe handle, duplicate the plugin's handle. | 243 // If the broker has its pipe handle, duplicate the plugin's handle. |
| 244 // Otherwise, the plugin's handle will be automatically closed. | 244 // Otherwise, the plugin's handle will be automatically closed. |
| 245 if (result == PP_OK) | 245 if (result == PP_OK) |
| 246 plugin_handle = DuplicateHandle(plugin_socket->handle()); | 246 plugin_handle = DuplicateHandle(plugin_socket->handle()); |
| 247 } else { | 247 } else { |
| 248 result = PP_ERROR_FAILED; | 248 result = PP_ERROR_FAILED; |
| 249 } | 249 } |
| 250 | 250 |
| 251 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing | 251 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing |
| 252 // client and plugin_socket.release(), then return. | 252 // client and plugin_socket.release(), then return. |
| 253 // That message handler will then call client->BrokerConnected() with the | 253 // That message handler will then call client->BrokerConnected() with the |
| 254 // saved pipe handle. | 254 // saved pipe handle. |
| 255 // Temporarily, just call back. | 255 // Temporarily, just call back. |
| 256 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); | 256 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace content | 259 } // namespace content |
| OLD | NEW |