| 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 #include "ppapi/shared_impl/proxy_lock.h" | 5 #include "ppapi/shared_impl/proxy_lock.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
| 9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
| 10 #include "ppapi/shared_impl/ppapi_globals.h" | 10 #include "ppapi/shared_impl/ppapi_globals.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 // static | 75 // static |
| 76 void ProxyLock::DisableLocking() { | 76 void ProxyLock::DisableLocking() { |
| 77 // Note, we don't DCHECK that this flag isn't already set, because multiple | 77 // Note, we don't DCHECK that this flag isn't already set, because multiple |
| 78 // unit tests may run in succession and all set it. | 78 // unit tests may run in succession and all set it. |
| 79 g_disable_locking = true; | 79 g_disable_locking = true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static | 82 ProxyLock::LockingDisablerForTest::LockingDisablerForTest() { |
| 83 void ProxyLock::DisableLockingOnThreadForTest() { | |
| 84 // Note, we don't DCHECK that this flag isn't already set, because multiple | 83 // Note, we don't DCHECK that this flag isn't already set, because multiple |
| 85 // unit tests may run in succession and all set it. | 84 // unit tests may run in succession and all set it. |
| 86 g_disable_locking_for_thread.Get().Set(true); | 85 g_disable_locking_for_thread.Get().Set(true); |
| 87 } | 86 } |
| 88 | 87 |
| 89 // static | 88 ProxyLock::LockingDisablerForTest::~LockingDisablerForTest() { |
| 90 void ProxyLock::EnableLockingOnThreadForTest() { | |
| 91 g_disable_locking_for_thread.Get().Set(false); | 89 g_disable_locking_for_thread.Get().Set(false); |
| 92 } | 90 } |
| 93 | 91 |
| 94 void CallWhileUnlocked(const base::Closure& closure) { | 92 void CallWhileUnlocked(const base::Closure& closure) { |
| 95 ProxyAutoUnlock lock; | 93 ProxyAutoUnlock lock; |
| 96 closure.Run(); | 94 closure.Run(); |
| 97 } | 95 } |
| 98 | 96 |
| 99 } // namespace ppapi | 97 } // namespace ppapi |
| OLD | NEW |