OLD | NEW |
1 // Copyright (c) 2011 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" |
(...skipping 16 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 | |
45 DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyLock); | 37 DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyLock); |
46 }; | 38 }; |
47 | 39 |
48 // A simple RAII class for locking the PPAPI proxy lock on entry and releasing | 40 // A simple RAII class for locking the PPAPI proxy lock on entry and releasing |
49 // on exit. This is for simple interfaces that don't use the 'thunk' system, | 41 // on exit. This is for simple interfaces that don't use the 'thunk' system, |
50 // such as PPB_Var and PPB_Core. | 42 // such as PPB_Var and PPB_Core. |
51 class ProxyAutoLock { | 43 class ProxyAutoLock { |
52 public: | 44 public: |
53 ProxyAutoLock() { | 45 ProxyAutoLock() { |
54 ProxyLock::Acquire(); | 46 ProxyLock::Acquire(); |
(...skipping 18 matching lines...) Expand all Loading... |
73 ProxyLock::Acquire(); | 65 ProxyLock::Acquire(); |
74 } | 66 } |
75 private: | 67 private: |
76 DISALLOW_COPY_AND_ASSIGN(ProxyAutoUnlock); | 68 DISALLOW_COPY_AND_ASSIGN(ProxyAutoUnlock); |
77 }; | 69 }; |
78 | 70 |
79 | 71 |
80 } // namespace ppapi | 72 } // namespace ppapi |
81 | 73 |
82 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ | 74 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ |
OLD | NEW |