Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: components/autofill/core/browser/test_autofill_clock.cc

Issue 2639403002: [Autofill] Remove direct use of base::Time::Now() in Autofill (Closed)
Patch Set: Added DCHECK Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/browser/test_autofill_clock.h"
6
7 #include <utility>
8
9 #include "base/test/simple_test_clock.h"
10 #include "components/autofill/core/common/autofill_clock.h"
11
12 namespace autofill {
13
14 TestAutofillClock::TestAutofillClock() {
15 // Create a new test clock and set it as the AutofillClock clock and keep a
16 // pointer to manipulate the time it returns.
17 std::unique_ptr<base::SimpleTestClock> unique_test_clock(
18 new base::SimpleTestClock());
19 // Keep a pointer to the clock to be able to use its SetNow() function.
20 test_clock_ = unique_test_clock.get();
21 AutofillClock::SetTestClock(std::move(unique_test_clock));
22 }
23
24 TestAutofillClock::~TestAutofillClock() {
25 // Destroys the test clock and resets a normal clock.
26 AutofillClock::SetClock();
27 }
28
29 void TestAutofillClock::SetNow(base::Time now) {
30 test_clock_->SetNow(now);
31 }
32
33 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698