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

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

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
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 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CLOCK_H_
6 #define COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CLOCK_H_
7
8 #include <memory>
9
10 #include "base/lazy_instance.h"
11 #include "base/macros.h"
12
13 namespace base {
14 class Clock;
15 class Time;
16 } // namespace base
17
18 namespace autofill {
19
20 // Handles getting the current time for the Autofill feature. Can be injected
21 // with a customizable clock to facilitate testing.
22 class AutofillClock {
23 public:
24 // Returns the current time based on |clock_|.
25 static base::Time Now();
26
27 private:
28 friend class TestAutofillClock;
29 friend struct base::DefaultLazyInstanceTraits<AutofillClock>;
30
31 // Resets a normal clock.
32 static void SetClock();
33
34 // Sets the clock to be used for tests.
35 static void SetTestClock(std::unique_ptr<base::Clock> clock);
36
37 AutofillClock();
38 ~AutofillClock();
39
40 // The clock used to return the current time.
41 std::unique_ptr<base::Clock> clock_;
42
43 DISALLOW_COPY_AND_ASSIGN(AutofillClock);
44 };
45
46 } // namespace autofill
47
48 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CLOCK_H_
OLDNEW
« no previous file with comments | « components/autofill/core/common/BUILD.gn ('k') | components/autofill/core/common/autofill_clock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698