| 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/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_ |
| OLD | NEW |