Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_ | |
| OLD | NEW |