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..d9b16402ac47bb583719a63a2624aed22d8b095e |
| --- /dev/null |
| +++ b/components/autofill/core/common/autofill_clock.cc |
| @@ -0,0 +1,34 @@ |
| +// 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" |
| + |
| +#include <utility> |
| + |
| +#include "base/time/clock.h" |
| +#include "base/time/default_clock.h" |
| + |
| +namespace autofill { |
| + |
| +std::unique_ptr<base::Clock> AutofillClock::clock_; |
|
Roger McFarlane (Chromium)
2017/01/31 19:05:54
I think the autofill clock might need to be a sing
sebsg
2017/01/31 21:55:56
Done.
|
| + |
| +// static |
| +base::Time AutofillClock::Now() { |
| + if (!clock_) |
| + SetClock(); |
| + |
| + return clock_->Now(); |
| +} |
| + |
| +// static |
| +void AutofillClock::SetClock() { |
| + clock_.reset(new base::DefaultClock()); |
| +} |
| + |
| +// static |
| +void AutofillClock::SetTestClock(std::unique_ptr<base::Clock> clock) { |
| + clock_ = std::move(clock); |
| +} |
| + |
| +} // namespace autofill |