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

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

Issue 225903006: PPAPI: Run clang_format.py on content/renderer/pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 8 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.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 22 matching lines...) Expand all
33 0, 33 0,
34 FALSE, 34 FALSE,
35 options)) { 35 options)) {
36 out_handle = base::kInvalidPlatformFileValue; 36 out_handle = base::kInvalidPlatformFileValue;
37 } 37 }
38 #elif defined(OS_POSIX) 38 #elif defined(OS_POSIX)
39 // If asked to close the source, we can simply re-use the source fd instead of 39 // If asked to close the source, we can simply re-use the source fd instead of
40 // dup()ing and close()ing. 40 // dup()ing and close()ing.
41 out_handle = ::dup(handle); 41 out_handle = ::dup(handle);
42 #else 42 #else
43 #error Not implemented. 43 #error Not implemented.
44 #endif 44 #endif
45 return out_handle; 45 return out_handle;
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 PepperBrokerDispatcherWrapper::PepperBrokerDispatcherWrapper() { 50 PepperBrokerDispatcherWrapper::PepperBrokerDispatcherWrapper() {}
51 }
52 51
53 PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() { 52 PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() {}
54 }
55 53
56 bool PepperBrokerDispatcherWrapper::Init( 54 bool PepperBrokerDispatcherWrapper::Init(
57 base::ProcessId broker_pid, 55 base::ProcessId broker_pid,
58 const IPC::ChannelHandle& channel_handle) { 56 const IPC::ChannelHandle& channel_handle) {
59 if (channel_handle.name.empty()) 57 if (channel_handle.name.empty())
60 return false; 58 return false;
61 59
62 #if defined(OS_POSIX) 60 #if defined(OS_POSIX)
63 DCHECK_NE(-1, channel_handle.socket.fd); 61 DCHECK_NE(-1, channel_handle.socket.fd);
64 if (channel_handle.socket.fd == -1) 62 if (channel_handle.socket.fd == -1)
65 return false; 63 return false;
66 #endif 64 #endif
67 65
68 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); 66 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
69 dispatcher_.reset( 67 dispatcher_.reset(new ppapi::proxy::BrokerHostDispatcher());
70 new ppapi::proxy::BrokerHostDispatcher());
71 68
72 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), 69 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(),
73 broker_pid, 70 broker_pid,
74 channel_handle, 71 channel_handle,
75 true)) { // Client. 72 true)) { // Client.
76 dispatcher_.reset(); 73 dispatcher_.reset();
77 dispatcher_delegate_.reset(); 74 dispatcher_delegate_.reset();
78 return false; 75 return false;
79 } 76 }
80 dispatcher_->channel()->SetRestrictDispatchChannelGroup( 77 dispatcher_->channel()->SetRestrictDispatchChannelGroup(
81 kRendererRestrictDispatchGroup_Pepper); 78 kRendererRestrictDispatchGroup_Pepper);
82 return true; 79 return true;
83 } 80 }
84 81
85 // Does not take ownership of the local pipe. 82 // Does not take ownership of the local pipe.
86 int32_t PepperBrokerDispatcherWrapper::SendHandleToBroker( 83 int32_t PepperBrokerDispatcherWrapper::SendHandleToBroker(
87 PP_Instance instance, 84 PP_Instance instance,
88 base::SyncSocket::Handle handle) { 85 base::SyncSocket::Handle handle) {
89 IPC::PlatformFileForTransit foreign_socket_handle = 86 IPC::PlatformFileForTransit foreign_socket_handle =
90 dispatcher_->ShareHandleWithRemote(handle, false); 87 dispatcher_->ShareHandleWithRemote(handle, false);
91 if (foreign_socket_handle == IPC::InvalidPlatformFileForTransit()) 88 if (foreign_socket_handle == IPC::InvalidPlatformFileForTransit())
92 return PP_ERROR_FAILED; 89 return PP_ERROR_FAILED;
93 90
94 int32_t result; 91 int32_t result;
95 if (!dispatcher_->Send( 92 if (!dispatcher_->Send(new PpapiMsg_ConnectToPlugin(
96 new PpapiMsg_ConnectToPlugin(instance, foreign_socket_handle, &result))) { 93 instance, foreign_socket_handle, &result))) {
97 // 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.
98 // 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
99 // and then close it. This failure case is not performance critical. 96 // and then close it. This failure case is not performance critical.
100 // 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.
101 base::SyncSocket temp_socket( 98 base::SyncSocket temp_socket(
102 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle)); 99 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle));
103 return PP_ERROR_FAILED; 100 return PP_ERROR_FAILED;
104 } 101 }
105 102
106 return result; 103 return result;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 pending_connects_.erase(entry); 199 pending_connects_.erase(entry);
203 return; 200 return;
204 } 201 }
205 202
206 // Mark the request as authorized, continue waiting for the broker 203 // Mark the request as authorized, continue waiting for the broker
207 // connection. 204 // connection.
208 DCHECK(!entry->second.is_authorized); 205 DCHECK(!entry->second.is_authorized);
209 entry->second.is_authorized = true; 206 entry->second.is_authorized = true;
210 } 207 }
211 208
212 PepperBroker::PendingConnection::PendingConnection() : is_authorized(false) { 209 PepperBroker::PendingConnection::PendingConnection() : is_authorized(false) {}
213 }
214 210
215 PepperBroker::PendingConnection::~PendingConnection() { 211 PepperBroker::PendingConnection::~PendingConnection() {}
216 }
217 212
218 void PepperBroker::ReportFailureToClients(int error_code) { 213 void PepperBroker::ReportFailureToClients(int error_code) {
219 DCHECK_NE(PP_OK, error_code); 214 DCHECK_NE(PP_OK, error_code);
220 for (ClientMap::iterator i = pending_connects_.begin(); 215 for (ClientMap::iterator i = pending_connects_.begin();
221 i != pending_connects_.end(); ++i) { 216 i != pending_connects_.end();
217 ++i) {
222 base::WeakPtr<PPB_Broker_Impl>& weak_ptr = i->second.client; 218 base::WeakPtr<PPB_Broker_Impl>& weak_ptr = i->second.client;
223 if (weak_ptr.get()) { 219 if (weak_ptr.get()) {
224 weak_ptr->BrokerConnected( 220 weak_ptr->BrokerConnected(
225 ppapi::PlatformFileToInt(base::kInvalidPlatformFileValue), 221 ppapi::PlatformFileToInt(base::kInvalidPlatformFileValue),
226 error_code); 222 error_code);
227 } 223 }
228 } 224 }
229 pending_connects_.clear(); 225 pending_connects_.clear();
230 } 226 }
231 227
(...skipping 19 matching lines...) Expand all
251 247
252 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing 248 // TOOD(ddorwin): Change the IPC to asynchronous: Queue an object containing
253 // client and plugin_socket.release(), then return. 249 // client and plugin_socket.release(), then return.
254 // That message handler will then call client->BrokerConnected() with the 250 // That message handler will then call client->BrokerConnected() with the
255 // saved pipe handle. 251 // saved pipe handle.
256 // Temporarily, just call back. 252 // Temporarily, just call back.
257 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result); 253 client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result);
258 } 254 }
259 255
260 } // namespace content 256 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_broker.h ('k') | content/renderer/pepper/pepper_browser_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698