| 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" |
| 11 |
| 10 namespace base { | 12 namespace base { |
| 11 class Lock; | 13 class Lock; |
| 12 } | 14 } |
| 13 | 15 |
| 14 namespace ppapi { | 16 namespace ppapi { |
| 15 | 17 |
| 16 // This is the one lock to rule them all for the ppapi proxy. All PPB interface | 18 // This is the one lock to rule them all for the ppapi proxy. All PPB interface |
| 17 // functions that need to be synchronized should lock this lock on entry. This | 19 // functions that need to be synchronized should lock this lock on entry. This |
| 18 // is normally accomplished by using an appropriate Enter RAII object at the | 20 // is normally accomplished by using an appropriate Enter RAII object at the |
| 19 // beginning of each thunk function. | 21 // beginning of each thunk function. |
| 20 // | 22 // |
| 21 // TODO(dmichael): If this turns out to be too slow and contentious, we'll want | 23 // TODO(dmichael): If this turns out to be too slow and contentious, we'll want |
| 22 // to use multiple locks. E.g., one for the var tracker, one for the resource | 24 // to use multiple locks. E.g., one for the var tracker, one for the resource |
| 23 // tracker, etc. | 25 // tracker, etc. |
| 24 class ProxyLock { | 26 class PPAPI_SHARED_EXPORT ProxyLock { |
| 25 public: | 27 public: |
| 26 // 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 |
| 27 // 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, |
| 28 // 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; |
| 29 // 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- |
| 30 // process plugin case. | 32 // process plugin case. |
| 31 static void Acquire(); | 33 static void Acquire(); |
| 32 // 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. |
| 33 static void Release(); | 35 static void Release(); |
| 34 | 36 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 ProxyLock::Acquire(); | 73 ProxyLock::Acquire(); |
| 72 } | 74 } |
| 73 private: | 75 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(ProxyAutoUnlock); | 76 DISALLOW_COPY_AND_ASSIGN(ProxyAutoUnlock); |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 | 79 |
| 78 } // namespace ppapi | 80 } // namespace ppapi |
| 79 | 81 |
| 80 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ | 82 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ |
| OLD | NEW |