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

Unified Diff: chrome/browser/ssl/ssl_error_classification.cc

Issue 1380483004: Make global variable g_testing_build_time lazily created (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to the newest master. Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/ssl_error_classification.cc
diff --git a/chrome/browser/ssl/ssl_error_classification.cc b/chrome/browser/ssl/ssl_error_classification.cc
index a93427463247d6d02fded77901c96f64d56d1866..450d6fb8a813fc31913f4de85748d9e6ad19ee93 100644
--- a/chrome/browser/ssl/ssl_error_classification.cc
+++ b/chrome/browser/ssl/ssl_error_classification.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/ssl/ssl_error_classification.h"
#include "base/build_time.h"
+#include "base/lazy_instance.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
@@ -85,7 +86,7 @@ int GetLevensteinDistance(const std::string& str1,
}
// The time to use when doing build time operations in browser tests.
-base::Time g_testing_build_time;
+base::LazyInstance<base::Time> g_testing_build_time = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -162,8 +163,8 @@ void SSLErrorClassification::RecordUMAStatistics(
bool SSLErrorClassification::IsUserClockInThePast(const base::Time& time_now) {
base::Time build_time;
- if (!g_testing_build_time.is_null()) {
- build_time = g_testing_build_time;
+ if (!g_testing_build_time.Get().is_null()) {
+ build_time = g_testing_build_time.Get();
} else {
#if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD)
return false;
@@ -180,8 +181,8 @@ bool SSLErrorClassification::IsUserClockInThePast(const base::Time& time_now) {
bool SSLErrorClassification::IsUserClockInTheFuture(
const base::Time& time_now) {
base::Time build_time;
- if (!g_testing_build_time.is_null()) {
- build_time = g_testing_build_time;
+ if (!g_testing_build_time.Get().is_null()) {
+ build_time = g_testing_build_time.Get();
} else {
#if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD)
return false;
@@ -198,7 +199,7 @@ bool SSLErrorClassification::IsUserClockInTheFuture(
// static
void SSLErrorClassification::SetBuildTimeForTesting(
const base::Time& testing_time) {
- g_testing_build_time = testing_time;
+ g_testing_build_time.Get() = testing_time;
}
bool SSLErrorClassification::MaybeWindowsLacksSHA256Support() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698