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

Unified Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 1851443003: Make global variable gTimeDeltaForTesting lazily created. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/banners/app_banner_data_fetcher.cc
diff --git a/chrome/browser/banners/app_banner_data_fetcher.cc b/chrome/browser/banners/app_banner_data_fetcher.cc
index a8c8c32fe2056f7a8df634f475ca16527abed7f2..5282804f1989c86e85569701dfd3f2b499e690f3 100644
--- a/chrome/browser/banners/app_banner_data_fetcher.cc
+++ b/chrome/browser/banners/app_banner_data_fetcher.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -31,7 +32,8 @@
namespace {
-base::TimeDelta gTimeDeltaForTesting;
+base::LazyInstance<base::TimeDelta> gTimeDeltaForTesting =
+ LAZY_INSTANCE_INITIALIZER;
int gCurrentRequestID = -1;
const char kPngExtension[] = ".png";
@@ -64,12 +66,12 @@ namespace banners {
// static
base::Time AppBannerDataFetcher::GetCurrentTime() {
- return base::Time::Now() + gTimeDeltaForTesting;
+ return base::Time::Now() + gTimeDeltaForTesting.Get();
}
// static
void AppBannerDataFetcher::SetTimeDeltaForTesting(int days) {
- gTimeDeltaForTesting = base::TimeDelta::FromDays(days);
+ gTimeDeltaForTesting.Get() = base::TimeDelta::FromDays(days);
}
AppBannerDataFetcher::AppBannerDataFetcher(content::WebContents* web_contents,
« 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