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

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 a scoped TestAutofillClock 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/macros.h"
11
12 namespace base {
13 class Clock;
14 class Time;
15 } // namespace base
16
17 namespace autofill {
18
19 // Handles getting the current time for the Autofill feature. Can be injected
20 // with a customizable clock to facilitate testing.
21 class AutofillClock {
22 public:
23 // Returns the current time base on |clock_|.
Mathieu 2017/01/31 18:19:37 *based on |clock_|
sebsg 2017/01/31 21:55:56 Done.
24 static base::Time Now();
25
26 private:
27 friend class TestAutofillClock;
28
29 // Resets a normal clock.
30 static void SetClock();
31
32 // Sets the clock to be used for tests.
33 static void SetTestClock(std::unique_ptr<base::Clock> clock);
34
35 static std::unique_ptr<base::Clock> clock_;
36
37 AutofillClock(){};
38 ~AutofillClock(){};
39
40 DISALLOW_COPY_AND_ASSIGN(AutofillClock);
41 };
42
43 } // namespace autofill
44
45 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CLOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698