OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 9 |
10 #include "ppapi/shared_impl/ppapi_shared_export.h" | 10 #include "ppapi/shared_impl/ppapi_shared_export.h" |
11 | 11 |
(...skipping 15 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 // Acquire the proxy lock. If it is currently held by another thread, block | 28 // Acquire the proxy lock. If it is currently held by another thread, block |
29 // until it is available. If the lock has not been set using the 'Set' method, | 29 // until it is available. If the lock has not been set using the 'Set' method, |
30 // this operation does nothing. That is the normal case for the host side; | 30 // this operation does nothing. That is the normal case for the host side; |
31 // see PluginResourceTracker for where the lock gets set for the out-of- | 31 // see PluginResourceTracker for where the lock gets set for the out-of- |
32 // process plugin case. | 32 // process plugin case. |
33 static void Acquire(); | 33 static void Acquire(); |
34 // Relinquish the proxy lock. If the lock has not been set, this does nothing. | 34 // Relinquish the proxy lock. If the lock has not been set, this does nothing. |
35 static void Release(); | 35 static void Release(); |
36 | 36 |
| 37 // Set the lock that ProxyLock will use. The caller is responsible for |
| 38 // ensuring that the lock stays valid so long as the ProxyLock may be in use. |
| 39 static void Set(base::Lock* lock); |
| 40 // Set the lock to NULL. |
| 41 static void Reset(); |
| 42 private: |
| 43 static base::Lock* lock_; |
| 44 |
37 DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyLock); | 45 DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyLock); |
38 }; | 46 }; |
39 | 47 |
40 // A simple RAII class for locking the PPAPI proxy lock on entry and releasing | 48 // A simple RAII class for locking the PPAPI proxy lock on entry and releasing |
41 // on exit. This is for simple interfaces that don't use the 'thunk' system, | 49 // on exit. This is for simple interfaces that don't use the 'thunk' system, |
42 // such as PPB_Var and PPB_Core. | 50 // such as PPB_Var and PPB_Core. |
43 class ProxyAutoLock { | 51 class ProxyAutoLock { |
44 public: | 52 public: |
45 ProxyAutoLock() { | 53 ProxyAutoLock() { |
46 ProxyLock::Acquire(); | 54 ProxyLock::Acquire(); |
(...skipping 18 matching lines...) Expand all Loading... |
65 ProxyLock::Acquire(); | 73 ProxyLock::Acquire(); |
66 } | 74 } |
67 private: | 75 private: |
68 DISALLOW_COPY_AND_ASSIGN(ProxyAutoUnlock); | 76 DISALLOW_COPY_AND_ASSIGN(ProxyAutoUnlock); |
69 }; | 77 }; |
70 | 78 |
71 | 79 |
72 } // namespace ppapi | 80 } // namespace ppapi |
73 | 81 |
74 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ | 82 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ |
OLD | NEW |