| 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_impl.h" | 5 #include "content/renderer/pepper/pepper_broker_impl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" | 8 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
| 9 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" | 9 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" |
| 10 #include "content/renderer/renderer_restrict_dispatch_group.h" | 10 #include "content/renderer/renderer_restrict_dispatch_group.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 PepperBrokerDispatcherWrapper::PepperBrokerDispatcherWrapper() { | 51 PepperBrokerDispatcherWrapper::PepperBrokerDispatcherWrapper() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() { | 54 PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() { |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool PepperBrokerDispatcherWrapper::Init( | 57 bool PepperBrokerDispatcherWrapper::Init( |
| 58 base::ProcessHandle broker_process_handle, | |
| 59 const IPC::ChannelHandle& channel_handle) { | 58 const IPC::ChannelHandle& channel_handle) { |
| 60 if (channel_handle.name.empty()) | 59 if (channel_handle.name.empty()) |
| 61 return false; | 60 return false; |
| 62 | 61 |
| 63 #if defined(OS_POSIX) | 62 #if defined(OS_POSIX) |
| 64 DCHECK_NE(-1, channel_handle.socket.fd); | 63 DCHECK_NE(-1, channel_handle.socket.fd); |
| 65 if (channel_handle.socket.fd == -1) | 64 if (channel_handle.socket.fd == -1) |
| 66 return false; | 65 return false; |
| 67 #endif | 66 #endif |
| 68 | 67 |
| 69 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); | 68 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); |
| 70 dispatcher_.reset( | 69 dispatcher_.reset( |
| 71 new ppapi::proxy::BrokerHostDispatcher(broker_process_handle)); | 70 new ppapi::proxy::BrokerHostDispatcher()); |
| 72 | 71 |
| 73 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), | 72 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), |
| 74 channel_handle, | 73 channel_handle, |
| 75 true)) { // Client. | 74 true)) { // Client. |
| 76 dispatcher_.reset(); | 75 dispatcher_.reset(); |
| 77 dispatcher_delegate_.reset(); | 76 dispatcher_delegate_.reset(); |
| 78 return false; | 77 return false; |
| 79 } | 78 } |
| 80 dispatcher_->channel()->SetRestrictDispatchChannelGroup( | 79 dispatcher_->channel()->SetRestrictDispatchChannelGroup( |
| 81 content::kRendererRestrictDispatchGroup_Pepper); | 80 content::kRendererRestrictDispatchGroup_Pepper); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 DCHECK(!stopped || HasOneRef()); | 183 DCHECK(!stopped || HasOneRef()); |
| 185 } | 184 } |
| 186 } | 185 } |
| 187 | 186 |
| 188 // Release the reference added in Connect(). | 187 // Release the reference added in Connect(). |
| 189 // This must be the last statement because it may delete this object. | 188 // This must be the last statement because it may delete this object. |
| 190 Release(); | 189 Release(); |
| 191 } | 190 } |
| 192 | 191 |
| 193 void PepperBrokerImpl::OnBrokerChannelConnected( | 192 void PepperBrokerImpl::OnBrokerChannelConnected( |
| 194 base::ProcessHandle broker_process_handle, | |
| 195 const IPC::ChannelHandle& channel_handle) { | 193 const IPC::ChannelHandle& channel_handle) { |
| 196 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher( | 194 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher( |
| 197 new PepperBrokerDispatcherWrapper); | 195 new PepperBrokerDispatcherWrapper); |
| 198 if (dispatcher->Init(broker_process_handle, channel_handle)) { | 196 if (dispatcher->Init(channel_handle)) { |
| 199 dispatcher_.reset(dispatcher.release()); | 197 dispatcher_.reset(dispatcher.release()); |
| 200 | 198 |
| 201 // Process all pending channel requests from the plugins. | 199 // Process all pending channel requests from the plugins. |
| 202 for (ClientMap::iterator i = pending_connects_.begin(); | 200 for (ClientMap::iterator i = pending_connects_.begin(); |
| 203 i != pending_connects_.end(); ++i) { | 201 i != pending_connects_.end(); ++i) { |
| 204 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; | 202 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; |
| 205 if (weak_ptr) | 203 if (weak_ptr) |
| 206 ConnectPluginToBroker(weak_ptr); | 204 ConnectPluginToBroker(weak_ptr); |
| 207 } | 205 } |
| 208 } else { | 206 } else { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 241 |
| 244 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing | 242 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing |
| 245 // client and plugin_socket.release(), then return. | 243 // client and plugin_socket.release(), then return. |
| 246 // That message handler will then call client->BrokerConnected() with the | 244 // That message handler will then call client->BrokerConnected() with the |
| 247 // saved pipe handle. | 245 // saved pipe handle. |
| 248 // Temporarily, just call back. | 246 // Temporarily, just call back. |
| 249 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); | 247 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); |
| 250 } | 248 } |
| 251 | 249 |
| 252 } // namespace content | 250 } // namespace content |
| OLD | NEW |