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

Side by Side Diff: components/autofill/core/common/autofill_clock.cc

Issue 2639403002: [Autofill] Remove direct use of base::Time::Now() in Autofill (Closed)
Patch Set: Added DCHECK Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « components/autofill/core/common/autofill_clock.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/autofill/core/common/autofill_clock.h"
6
7 #include <utility>
8
9 #include "base/time/clock.h"
10 #include "base/time/default_clock.h"
11
12 namespace autofill {
13
14 namespace {
15
16 static base::LazyInstance<AutofillClock> g_autofill_clock =
17 LAZY_INSTANCE_INITIALIZER;
18
19 } // namespace
20
21 // static
22 base::Time AutofillClock::Now() {
23 if (!g_autofill_clock.Get().clock_)
24 SetClock();
25
26 return g_autofill_clock.Get().clock_->Now();
27 }
28
29 AutofillClock::AutofillClock(){};
30 AutofillClock::~AutofillClock(){};
31
32 // static
33 void AutofillClock::SetClock() {
34 g_autofill_clock.Get().clock_.reset(new base::DefaultClock());
35 }
36
37 // static
38 void AutofillClock::SetTestClock(std::unique_ptr<base::Clock> clock) {
39 DCHECK(clock);
40 g_autofill_clock.Get().clock_ = std::move(clock);
41 }
42
43 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/common/autofill_clock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698