Chromium Code Reviews| Index: components/autofill/core/common/autofill_clock.cc |
| diff --git a/components/autofill/core/common/autofill_clock.cc b/components/autofill/core/common/autofill_clock.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..efac5754a0407dababa23f7a18487580466de617 |
| --- /dev/null |
| +++ b/components/autofill/core/common/autofill_clock.cc |
| @@ -0,0 +1,35 @@ |
| +// 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. |
| + |
| +#include "components/autofill/core/common/autofill_clock.h" |
| + |
|
Mathieu
2017/01/25 22:32:14
#include <utility>
sebsg
2017/01/30 20:27:26
Done.
|
| +#include "base/time/clock.h" |
| +#include "base/time/default_clock.h" |
| + |
| +namespace autofill { |
| + |
| +namespace { |
| + |
| +static base::LazyInstance<AutofillClock> g_autofill_clock = |
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| +} // namespace |
| + |
| +// static |
| +base::Time AutofillClock::Now() { |
| + return g_autofill_clock.Get().clock_->Now(); |
| +} |
| + |
| +AutofillClock::AutofillClock() { |
| + clock_.reset(new base::DefaultClock()); |
| +} |
| + |
| +AutofillClock::~AutofillClock() {} |
| + |
| +// static |
| +void AutofillClock::SetClockForTests(std::unique_ptr<base::Clock> clock) { |
| + g_autofill_clock.Get().clock_ = std::move(clock); |
| +} |
| + |
| +} // namespace autofill |