Chromium Code Reviews| Index: components/autofill/core/common/autofill_clock.h |
| diff --git a/components/autofill/core/common/autofill_clock.h b/components/autofill/core/common/autofill_clock.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f9f3f0926ae0468a3444047291ab4ec725078aec |
| --- /dev/null |
| +++ b/components/autofill/core/common/autofill_clock.h |
| @@ -0,0 +1,45 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CLOCK_H_ |
| +#define COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CLOCK_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/macros.h" |
| + |
| +namespace base { |
| +class Clock; |
| +class Time; |
| +} // namespace base |
| + |
| +namespace autofill { |
| + |
| +// Handles getting the current time for the Autofill feature. Can be injected |
| +// with a customizable clock to facilitate testing. |
| +class AutofillClock { |
| + public: |
| + // 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.
|
| + static base::Time Now(); |
| + |
| + private: |
| + friend class TestAutofillClock; |
| + |
| + // Resets a normal clock. |
| + static void SetClock(); |
| + |
| + // Sets the clock to be used for tests. |
| + static void SetTestClock(std::unique_ptr<base::Clock> clock); |
| + |
| + static std::unique_ptr<base::Clock> clock_; |
| + |
| + AutofillClock(){}; |
| + ~AutofillClock(){}; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AutofillClock); |
| +}; |
| + |
| +} // namespace autofill |
| + |
| +#endif // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_CLOCK_H_ |