Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
|
Mathieu
2017/01/25 19:57:24
+4
sebsg
2017/01/25 21:35:27
Done.
| |
| 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/browser/autofill_clock.h" | |
|
Mathieu
2017/01/25 19:57:24
does it make sense to have this in core/common?
sebsg
2017/01/25 21:35:27
Done.
| |
| 6 | |
| 7 #include "base/time/clock.h" | |
| 8 #include "base/time/default_clock.h" | |
| 9 | |
| 10 namespace autofill { | |
| 11 | |
| 12 static base::LazyInstance<AutofillClock> instance_ = LAZY_INSTANCE_INITIALIZER; | |
|
Mathieu
2017/01/25 19:57:24
can this be in the anonymous namespace?
Mathieu
2017/01/25 19:57:24
naming style is probably to have g_autofill_clock
sebsg
2017/01/25 21:35:26
Done.
sebsg
2017/01/25 21:35:27
Done.
| |
| 13 | |
| 14 // static | |
| 15 base::Time AutofillClock::Now() { | |
| 16 return instance_.Get().clock_->Now(); | |
| 17 } | |
| 18 | |
| 19 AutofillClock::AutofillClock() { | |
| 20 clock_ = base::MakeUnique<base::DefaultClock>(); | |
|
Mathieu
2017/01/25 19:57:24
I prefer the style
clock_.reset(new base::Defaul
sebsg
2017/01/25 21:35:27
Done.
| |
| 21 } | |
| 22 | |
| 23 AutofillClock::~AutofillClock() {} | |
| 24 | |
| 25 // static | |
| 26 void AutofillClock::SetClockForTests(base::Clock* clock) { | |
|
Mathieu
2017/01/25 19:57:24
probably better to pass a std::unique_ptr? makes o
sebsg
2017/01/25 21:35:27
True, thanks for the suggestion.
| |
| 27 instance_.Get().clock_.reset(clock); | |
| 28 } | |
| 29 | |
| 30 } // namespace autofill | |
| OLD | NEW |