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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 static void AssertAcquired(); | 52 static void AssertAcquired(); |
53 static void AssertAcquiredDebugOnly() { | 53 static void AssertAcquiredDebugOnly() { |
54 #ifndef NDEBUG | 54 #ifndef NDEBUG |
55 AssertAcquired(); | 55 AssertAcquired(); |
56 #endif | 56 #endif |
57 } | 57 } |
58 | 58 |
59 // 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 |
60 // 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 |
61 // thread to support these tests. See TwoWayTest for more information. | 61 // thread to support these tests. See TwoWayTest for more information. |
62 static void DisableLockingOnThreadForTest(); | 62 class PPAPI_SHARED_EXPORT LockingDisablerForTest { |
63 | 63 public: |
64 // Enables locking on the current thread. Although locking is enabled by | 64 LockingDisablerForTest(); |
65 // default, unit tests that rely on the lock being enabled should *still* | 65 ~LockingDisablerForTest(); |
66 // call this, since a previous test may have disabled locking. | 66 }; |
67 static void EnableLockingOnThreadForTest(); | |
68 | 67 |
69 private: | 68 private: |
70 friend class content::HostGlobals; | 69 friend class content::HostGlobals; |
71 // On the host side, we do not lock. This must be called at most once at | 70 // On the host side, we do not lock. This must be called at most once at |
72 // startup, before other threads that may access the ProxyLock have had a | 71 // startup, before other threads that may access the ProxyLock have had a |
73 // chance to run. | 72 // chance to run. |
74 static void DisableLocking(); | 73 static void DisableLocking(); |
75 | 74 |
76 DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyLock); | 75 DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyLock); |
77 }; | 76 }; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 internal::RunWhileLockedHelper<FunctionType>* helper = | 358 internal::RunWhileLockedHelper<FunctionType>* helper = |
360 new internal::RunWhileLockedHelper<FunctionType>(callback); | 359 new internal::RunWhileLockedHelper<FunctionType>(callback); |
361 return base::Bind( | 360 return base::Bind( |
362 &internal::RunWhileLockedHelper<FunctionType>::CallWhileLocked, | 361 &internal::RunWhileLockedHelper<FunctionType>::CallWhileLocked, |
363 base::Owned(helper)); | 362 base::Owned(helper)); |
364 } | 363 } |
365 | 364 |
366 } // namespace ppapi | 365 } // namespace ppapi |
367 | 366 |
368 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ | 367 #endif // PPAPI_SHARED_IMPL_PROXY_LOCK_H_ |
OLD | NEW |