| OLD | NEW |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // this operation does nothing. That is the normal case for the host side; | 43 // this operation does nothing. That is the normal case for the host side; |
| 44 // see PluginResourceTracker for where the lock gets set for the out-of- | 44 // see PluginResourceTracker for where the lock gets set for the out-of- |
| 45 // process plugin case. | 45 // process plugin case. |
| 46 static void Acquire(); | 46 static void Acquire(); |
| 47 // Relinquish the proxy lock. If the lock has not been set, this does nothing. | 47 // Relinquish the proxy lock. If the lock has not been set, this does nothing. |
| 48 static void Release(); | 48 static void Release(); |
| 49 | 49 |
| 50 // Assert that the lock is owned by the current thread (in the plugin | 50 // Assert that the lock is owned by the current thread (in the plugin |
| 51 // process). Does nothing when running in-process (or in the host process). | 51 // process). Does nothing when running in-process (or in the host process). |
| 52 static void AssertAcquired(); | 52 static void AssertAcquired(); |
| 53 static void AssertAcquiredDebugOnly() { |
| 54 #ifndef NDEBUG |
| 55 AssertAcquired(); |
| 56 #endif |
| 57 } |
| 53 | 58 |
| 54 // We have some unit tests where one thread pretends to be the host and one | 59 // We have some unit tests where one thread pretends to be the host and one |
| 55 // pretends to be the plugin. This allows the lock to do nothing on only one | 60 // pretends to be the plugin. This allows the lock to do nothing on only one |
| 56 // thread to support these tests. See TwoWayTest for more information. | 61 // thread to support these tests. See TwoWayTest for more information. |
| 57 static void DisableLockingOnThreadForTest(); | 62 static void DisableLockingOnThreadForTest(); |
| 58 | 63 |
| 59 // Enables locking on the current thread. Although locking is enabled by | 64 // Enables locking on the current thread. Although locking is enabled by |
| 60 // default, unit tests that rely on the lock being enabled should *still* | 65 // default, unit tests that rely on the lock being enabled should *still* |
| 61 // call this, since a previous test may have disabled locking. | 66 // call this, since a previous test may have disabled locking. |
| 62 static void EnableLockingOnThreadForTest(); | 67 static void EnableLockingOnThreadForTest(); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 internal::RunWhileLockedHelper<FunctionType>* helper = | 354 internal::RunWhileLockedHelper<FunctionType>* helper = |
| 350 new internal::RunWhileLockedHelper<FunctionType>(callback); | 355 new internal::RunWhileLockedHelper<FunctionType>(callback); |
| 351 return base::Bind( | 356 return base::Bind( |
| 352 &internal::RunWhileLockedHelper<FunctionType>::CallWhileLocked, | 357 &internal::RunWhileLockedHelper<FunctionType>::CallWhileLocked, |
| 353 base::Owned(helper)); | 358 base::Owned(helper)); |
| 354 } | 359 } |
| 355 | 360 |
| 356 } // namespace ppapi | 361 } // namespace ppapi |
| 357 | 362 |
| 358 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ | 363 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ |
| OLD | NEW |