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

Side by Side Diff: ppapi/shared_impl/proxy_lock.h

Issue 552423003: PPAPI: Make CallWhileUnlocked more permissive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « ppapi/proxy/video_capture_resource.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef PPAPI_SHARED_IMPL_PROXY_LOCK_H_ 5 #ifndef PPAPI_SHARED_IMPL_PROXY_LOCK_H_
6 #define PPAPI_SHARED_IMPL_PROXY_LOCK_H_ 6 #define PPAPI_SHARED_IMPL_PROXY_LOCK_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // 110 //
111 // Example usage: 111 // Example usage:
112 // *result = CallWhileUnlocked(ppp_input_event_impl_->HandleInputEvent, 112 // *result = CallWhileUnlocked(ppp_input_event_impl_->HandleInputEvent,
113 // instance, 113 // instance,
114 // resource->pp_resource()); 114 // resource->pp_resource());
115 template <class ReturnType> 115 template <class ReturnType>
116 ReturnType CallWhileUnlocked(ReturnType (*function)()) { 116 ReturnType CallWhileUnlocked(ReturnType (*function)()) {
117 ProxyAutoUnlock unlock; 117 ProxyAutoUnlock unlock;
118 return function(); 118 return function();
119 } 119 }
120 template <class ReturnType, class P1> 120 // Note we use 2 types for the params, even though for the most part we expect
121 ReturnType CallWhileUnlocked(ReturnType (*function)(P1), const P1& p1) { 121 // A1 to match P1. We let the compiler determine if P1 can convert safely to
122 // A1. This allows callers to avoid having to do things like
123 // const_cast to add const.
124 template <class ReturnType, class A1, class P1>
125 ReturnType CallWhileUnlocked(ReturnType (*function)(A1), const P1& p1) {
122 ProxyAutoUnlock unlock; 126 ProxyAutoUnlock unlock;
123 return function(p1); 127 return function(p1);
124 } 128 }
125 template <class ReturnType, class P1, class P2> 129 template <class ReturnType, class A1, class A2, class P1, class P2>
126 ReturnType CallWhileUnlocked(ReturnType (*function)(P1, P2), 130 ReturnType CallWhileUnlocked(ReturnType (*function)(A1, A2),
127 const P1& p1, 131 const P1& p1,
128 const P2& p2) { 132 const P2& p2) {
129 ProxyAutoUnlock unlock; 133 ProxyAutoUnlock unlock;
130 return function(p1, p2); 134 return function(p1, p2);
131 } 135 }
132 template <class ReturnType, class P1, class P2, class P3> 136 template <class ReturnType, class A1, class A2, class A3, class P1, class P2,
133 ReturnType CallWhileUnlocked(ReturnType (*function)(P1, P2, P3), 137 class P3>
138 ReturnType CallWhileUnlocked(ReturnType (*function)(A1, A2, A3),
134 const P1& p1, 139 const P1& p1,
135 const P2& p2, 140 const P2& p2,
136 const P3& p3) { 141 const P3& p3) {
137 ProxyAutoUnlock unlock; 142 ProxyAutoUnlock unlock;
138 return function(p1, p2, p3); 143 return function(p1, p2, p3);
139 } 144 }
140 template <class ReturnType, class P1, class P2, class P3, class P4> 145 template <class ReturnType, class A1, class A2, class A3, class A4, class P1,
141 ReturnType CallWhileUnlocked(ReturnType (*function)(P1, P2, P3, P4), 146 class P2, class P3, class P4>
147 ReturnType CallWhileUnlocked(ReturnType (*function)(A1, A2, A3, A4),
142 const P1& p1, 148 const P1& p1,
143 const P2& p2, 149 const P2& p2,
144 const P3& p3, 150 const P3& p3,
145 const P4& p4) { 151 const P4& p4) {
146 ProxyAutoUnlock unlock; 152 ProxyAutoUnlock unlock;
147 return function(p1, p2, p3, p4); 153 return function(p1, p2, p3, p4);
148 } 154 }
149 template <class ReturnType, class P1, class P2, class P3, class P4, class P5> 155 template <class ReturnType, class A1, class A2, class A3, class A4, class A5,
150 ReturnType CallWhileUnlocked(ReturnType (*function)(P1, P2, P3, P4, P5), 156 class P1, class P2, class P3, class P4, class P5>
157 ReturnType CallWhileUnlocked(ReturnType (*function)(A1, A2, A3, A4, A5),
151 const P1& p1, 158 const P1& p1,
152 const P2& p2, 159 const P2& p2,
153 const P3& p3, 160 const P3& p3,
154 const P4& p4, 161 const P4& p4,
155 const P5& p5) { 162 const P5& p5) {
156 ProxyAutoUnlock unlock; 163 ProxyAutoUnlock unlock;
157 return function(p1, p2, p3, p4, p5); 164 return function(p1, p2, p3, p4, p5);
158 } 165 }
159 void PPAPI_SHARED_EXPORT CallWhileUnlocked(const base::Closure& closure); 166 void PPAPI_SHARED_EXPORT CallWhileUnlocked(const base::Closure& closure);
160 167
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 internal::RunWhileLockedHelper<FunctionType>* helper = 359 internal::RunWhileLockedHelper<FunctionType>* helper =
353 new internal::RunWhileLockedHelper<FunctionType>(callback); 360 new internal::RunWhileLockedHelper<FunctionType>(callback);
354 return base::Bind( 361 return base::Bind(
355 &internal::RunWhileLockedHelper<FunctionType>::CallWhileLocked, 362 &internal::RunWhileLockedHelper<FunctionType>::CallWhileLocked,
356 base::Owned(helper)); 363 base::Owned(helper));
357 } 364 }
358 365
359 } // namespace ppapi 366 } // namespace ppapi
360 367
361 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ 368 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/video_capture_resource.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698