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

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

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 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
« no previous file with comments | « ppapi/shared_impl/private/udp_socket_private_impl.cc ('k') | ppapi/shared_impl/proxy_lock.cc » ('j') | 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 template <class ReturnType, class P1, class P2, class P3, class P4, class P5> 119 template <class ReturnType, class P1, class P2, class P3, class P4, class P5>
120 ReturnType CallWhileUnlocked(ReturnType (*function)(P1, P2, P3, P4, P5), 120 ReturnType CallWhileUnlocked(ReturnType (*function)(P1, P2, P3, P4, P5),
121 const P1& p1, 121 const P1& p1,
122 const P2& p2, 122 const P2& p2,
123 const P3& p3, 123 const P3& p3,
124 const P4& p4, 124 const P4& p4,
125 const P5& p5) { 125 const P5& p5) {
126 ProxyAutoUnlock unlock; 126 ProxyAutoUnlock unlock;
127 return function(p1, p2, p3, p4, p5); 127 return function(p1, p2, p3, p4, p5);
128 } 128 }
129 void PPAPI_SHARED_EXPORT CallWhileUnlocked(const base::Closure& closure);
129 130
130 // CallWhileLocked locks the ProxyLock and runs the given closure immediately. 131 // CallWhileLocked locks the ProxyLock and runs the given closure immediately.
131 // The lock is released when CallWhileLocked returns. This function assumes the 132 // The lock is released when CallWhileLocked returns. This function assumes the
132 // lock is not held. This is mostly for use in RunWhileLocked; see below. 133 // lock is not held. This is mostly for use in RunWhileLocked; see below.
133 void PPAPI_SHARED_EXPORT CallWhileLocked(const base::Closure& closure); 134 void PPAPI_SHARED_EXPORT CallWhileLocked(const base::Closure& closure);
134 135
135 // RunWhileLocked binds the given closure with CallWhileLocked and returns the 136 // RunWhileLocked binds the given closure with CallWhileLocked and returns the
136 // new Closure. This is for cases where you want to run a task, but you want to 137 // new Closure. This is for cases where you want to run a task, but you want to
137 // ensure that the ProxyLock is acquired for the duration of the task. 138 // ensure that the ProxyLock is acquired for the duration of the task.
138 // Example usage: 139 // Example usage:
139 // GetMainThreadMessageLoop()->PostDelayedTask( 140 // GetMainThreadMessageLoop()->PostDelayedTask(
140 // FROM_HERE, 141 // FROM_HERE,
141 // RunWhileLocked(base::Bind(&CallbackWrapper, callback, result)), 142 // RunWhileLocked(base::Bind(&CallbackWrapper, callback, result)),
142 // delay_in_ms); 143 // delay_in_ms);
143 inline base::Closure RunWhileLocked(const base::Closure& closure) { 144 inline base::Closure RunWhileLocked(const base::Closure& closure) {
144 return base::Bind(CallWhileLocked, closure); 145 return base::Bind(CallWhileLocked, closure);
145 } 146 }
146 147
147 } // namespace ppapi 148 } // namespace ppapi
148 149
149 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ 150 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/private/udp_socket_private_impl.cc ('k') | ppapi/shared_impl/proxy_lock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698