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

Unified Diff: base/time/time_posix.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_posix.cc
diff --git a/base/time/time_posix.cc b/base/time/time_posix.cc
index 963c15b6536fa52b46b2dd903d21fa264c10ca3f..ada2058563f2e3f51b8527bf46bbb1490c31bc8a 100644
--- a/base/time/time_posix.cc
+++ b/base/time/time_posix.cc
@@ -26,7 +26,6 @@
#endif
#if !defined(OS_MACOSX)
-#include "base/lazy_instance.h"
#include "base/synchronization/lock.h"
#endif
@@ -35,8 +34,10 @@ namespace {
#if !defined(OS_MACOSX)
// This prevents a crash on traversing the environment global and looking up
// the 'TZ' variable in libc. See: crbug.com/390567.
-base::LazyInstance<base::Lock>::Leaky
- g_sys_time_to_time_struct_lock = LAZY_INSTANCE_INITIALIZER;
+base::Lock* GetSysTimeToTimeStructLock() {
+ static auto lock = new base::Lock();
+ return lock;
+}
// Define a system-specific SysTime that wraps either to a time_t or
// a time64_t depending on the host system, and associated convertion.
@@ -45,7 +46,7 @@ base::LazyInstance<base::Lock>::Leaky
typedef time64_t SysTime;
SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) {
- base::AutoLock locked(g_sys_time_to_time_struct_lock.Get());
+ base::AutoLock locked(*GetSysTimeToTimeStructLock());
if (is_local)
return mktime64(timestruct);
else
@@ -53,7 +54,7 @@ SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) {
}
void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) {
- base::AutoLock locked(g_sys_time_to_time_struct_lock.Get());
+ base::AutoLock locked(*GetSysTimeToTimeStructLock());
if (is_local)
localtime64_r(&t, timestruct);
else
@@ -64,7 +65,7 @@ void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) {
typedef time_t SysTime;
SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) {
- base::AutoLock locked(g_sys_time_to_time_struct_lock.Get());
+ base::AutoLock locked(*GetSysTimeToTimeStructLock());
if (is_local)
return mktime(timestruct);
else
@@ -72,7 +73,7 @@ SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) {
}
void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) {
- base::AutoLock locked(g_sys_time_to_time_struct_lock.Get());
+ base::AutoLock locked(*GetSysTimeToTimeStructLock());
if (is_local)
localtime_r(&t, timestruct);
else

Powered by Google App Engine
This is Rietveld 408576698