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 #include "components/autofill/core/common/autofill_clock.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/time/clock.h" | |
| 10 #include "base/time/default_clock.h" | |
| 11 | |
| 12 namespace autofill { | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 static base::LazyInstance<AutofillClock> g_autofill_clock = | |
| 17 LAZY_INSTANCE_INITIALIZER; | |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 // static | |
| 22 base::Time AutofillClock::Now() { | |
| 23 if (!g_autofill_clock.Get().clock_) | |
| 24 SetClock(); | |
| 25 | |
| 26 return g_autofill_clock.Get().clock_->Now(); | |
| 27 } | |
| 28 | |
| 29 AutofillClock::AutofillClock(){}; | |
| 30 AutofillClock::~AutofillClock(){}; | |
| 31 | |
| 32 // static | |
| 33 void AutofillClock::SetClock() { | |
| 34 g_autofill_clock.Get().clock_.reset(new base::DefaultClock()); | |
| 35 } | |
| 36 | |
| 37 // static | |
| 38 void AutofillClock::SetTestClock(std::unique_ptr<base::Clock> clock) { | |
|
Roger McFarlane (Chromium)
2017/02/01 15:34:26
DCHECK(clock != nullptr)
?
sebsg
2017/02/01 18:25:57
Done.
| |
| 39 g_autofill_clock.Get().clock_ = std::move(clock); | |
| 40 } | |
| 41 | |
| 42 } // namespace autofill | |
| OLD | NEW |