Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: content/renderer/pepper/pepper_broker_impl.cc

Issue 11722017: Use an explicit PID for duplicating Pepper handles rather than the Channel's. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/public/renderer/renderer_restrict_dispatch_group.h" 8 #include "content/public/renderer/renderer_restrict_dispatch_group.h"
9 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" 9 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
10 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" 10 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::ProcessId broker_pid,
58 const IPC::ChannelHandle& channel_handle) { 59 const IPC::ChannelHandle& channel_handle) {
59 if (channel_handle.name.empty()) 60 if (channel_handle.name.empty())
60 return false; 61 return false;
61 62
62 #if defined(OS_POSIX) 63 #if defined(OS_POSIX)
63 DCHECK_NE(-1, channel_handle.socket.fd); 64 DCHECK_NE(-1, channel_handle.socket.fd);
64 if (channel_handle.socket.fd == -1) 65 if (channel_handle.socket.fd == -1)
65 return false; 66 return false;
66 #endif 67 #endif
67 68
68 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); 69 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
69 dispatcher_.reset( 70 dispatcher_.reset(
70 new ppapi::proxy::BrokerHostDispatcher()); 71 new ppapi::proxy::BrokerHostDispatcher());
71 72
72 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), 73 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(),
74 broker_pid,
73 channel_handle, 75 channel_handle,
74 true)) { // Client. 76 true)) { // Client.
75 dispatcher_.reset(); 77 dispatcher_.reset();
76 dispatcher_delegate_.reset(); 78 dispatcher_delegate_.reset();
77 return false; 79 return false;
78 } 80 }
79 dispatcher_->channel()->SetRestrictDispatchChannelGroup( 81 dispatcher_->channel()->SetRestrictDispatchChannelGroup(
80 content::kRendererRestrictDispatchGroup_Pepper); 82 content::kRendererRestrictDispatchGroup_Pepper);
81 return true; 83 return true;
82 } 84 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 DCHECK(!stopped || HasOneRef()); 169 DCHECK(!stopped || HasOneRef());
168 } 170 }
169 } 171 }
170 172
171 // Release the reference added in Connect(). 173 // Release the reference added in Connect().
172 // This must be the last statement because it may delete this object. 174 // This must be the last statement because it may delete this object.
173 Release(); 175 Release();
174 } 176 }
175 177
176 void PepperBrokerImpl::OnBrokerChannelConnected( 178 void PepperBrokerImpl::OnBrokerChannelConnected(
179 base::ProcessId broker_pid,
177 const IPC::ChannelHandle& channel_handle) { 180 const IPC::ChannelHandle& channel_handle) {
178 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher( 181 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher(
179 new PepperBrokerDispatcherWrapper); 182 new PepperBrokerDispatcherWrapper);
180 if (!dispatcher->Init(channel_handle)) { 183 if (!dispatcher->Init(broker_pid, channel_handle)) {
181 ReportFailureToClients(PP_ERROR_FAILED); 184 ReportFailureToClients(PP_ERROR_FAILED);
182 return; 185 return;
183 } 186 }
184 187
185 dispatcher_.reset(dispatcher.release()); 188 dispatcher_.reset(dispatcher.release());
186 189
187 // Process all pending channel requests from the plugins. 190 // Process all pending channel requests from the plugins.
188 for (ClientMap::iterator i = pending_connects_.begin(); 191 for (ClientMap::iterator i = pending_connects_.begin();
189 i != pending_connects_.end();) { 192 i != pending_connects_.end();) {
190 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = 193 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr =
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 283
281 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing 284 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing
282 // client and plugin_socket.release(), then return. 285 // client and plugin_socket.release(), then return.
283 // That message handler will then call client->BrokerConnected() with the 286 // That message handler will then call client->BrokerConnected() with the
284 // saved pipe handle. 287 // saved pipe handle.
285 // Temporarily, just call back. 288 // Temporarily, just call back.
286 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); 289 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result);
287 } 290 }
288 291
289 } // namespace content 292 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_broker_impl.h ('k') | content/renderer/pepper/pepper_broker_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698