OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/domain_reliability/test_util.h" | 5 #include "components/domain_reliability/test_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "net/url_request/url_request_status.h" | 8 #include "net/url_request/url_request_status.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace domain_reliability { | 11 namespace domain_reliability { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 class MockTimer : public MockableTime::Timer { | 15 class MockTimer : public MockableTime::Timer { |
16 public: | 16 public: |
17 MockTimer(MockTime* time) | 17 MockTimer(MockTime* time) |
18 : time_(time), | 18 : time_(time), |
19 running_(false), | 19 running_(false), |
20 callback_sequence_number_(0), | 20 callback_sequence_number_(0), |
21 weak_factory_(this) { | 21 weak_factory_(this) { |
22 DCHECK(time); | 22 DCHECK(time); |
23 } | 23 } |
| 24 |
24 virtual ~MockTimer() {} | 25 virtual ~MockTimer() {} |
25 | 26 |
26 // MockableTime::Timer implementation: | 27 // MockableTime::Timer implementation: |
27 virtual void Start(const tracked_objects::Location& posted_from, | 28 virtual void Start(const tracked_objects::Location& posted_from, |
28 base::TimeDelta delay, | 29 base::TimeDelta delay, |
29 const base::Closure& user_task) OVERRIDE { | 30 const base::Closure& user_task) OVERRIDE { |
30 DCHECK(!user_task.is_null()); | 31 DCHECK(!user_task.is_null()); |
31 | 32 |
32 if (running_) | 33 if (running_) |
33 ++callback_sequence_number_; | 34 ++callback_sequence_number_; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 tasks_[TaskKey(now_ticks_ + delay, task_sequence_number_++)] = task; | 137 tasks_[TaskKey(now_ticks_ + delay, task_sequence_number_++)] = task; |
137 } | 138 } |
138 | 139 |
139 void MockTime::AdvanceToInternal(base::TimeTicks target_ticks) { | 140 void MockTime::AdvanceToInternal(base::TimeTicks target_ticks) { |
140 base::TimeDelta delta = target_ticks - now_ticks_; | 141 base::TimeDelta delta = target_ticks - now_ticks_; |
141 now_ += delta; | 142 now_ += delta; |
142 now_ticks_ += delta; | 143 now_ticks_ += delta; |
143 } | 144 } |
144 | 145 |
145 } // namespace domain_reliability | 146 } // namespace domain_reliability |
OLD | NEW |