Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3415)

Unified Diff: base/time/time_win.cc

Issue 2667513003: Remove some LazyInstance use in base/ (Closed)
Patch Set: no message_window Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/time/time_win.cc
diff --git a/base/time/time_win.cc b/base/time/time_win.cc
index 19144cb2792e376c648f30bde3b2f3757645dbfb..75f398d60f654267e37862a5ed477468f78000bc 100644
--- a/base/time/time_win.cc
+++ b/base/time/time_win.cc
@@ -40,7 +40,6 @@
#include "base/atomicops.h"
#include "base/bit_cast.h"
#include "base/cpu.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
@@ -97,8 +96,10 @@ bool g_high_res_timer_enabled = false;
// How many times the high resolution timer has been called.
uint32_t g_high_res_timer_count = 0;
// The lock to control access to the above two variables.
-base::LazyInstance<base::Lock>::Leaky g_high_res_lock =
- LAZY_INSTANCE_INITIALIZER;
+base::Lock* GetHighResLock() {
+ static auto lock = new base::Lock();
+ return lock;
+}
// Returns the current value of the performance counter.
uint64_t QPCNowRaw() {
@@ -191,7 +192,7 @@ FILETIME Time::ToFileTime() const {
// static
void Time::EnableHighResolutionTimer(bool enable) {
- base::AutoLock lock(g_high_res_lock.Get());
+ base::AutoLock lock(*GetHighResLock());
if (g_high_res_timer_enabled == enable)
return;
g_high_res_timer_enabled = enable;
@@ -218,7 +219,7 @@ bool Time::ActivateHighResolutionTimer(bool activating) {
// called.
const uint32_t max = std::numeric_limits<uint32_t>::max();
- base::AutoLock lock(g_high_res_lock.Get());
+ base::AutoLock lock(*GetHighResLock());
UINT period = g_high_res_timer_enabled ? kMinTimerIntervalHighResMs
: kMinTimerIntervalLowResMs;
if (activating) {
@@ -237,7 +238,7 @@ bool Time::ActivateHighResolutionTimer(bool activating) {
// static
bool Time::IsHighResolutionTimerInUse() {
- base::AutoLock lock(g_high_res_lock.Get());
+ base::AutoLock lock(*GetHighResLock());
return g_high_res_timer_enabled && g_high_res_timer_count > 0;
}

Powered by Google App Engine
This is Rietveld 408576698