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/util.h" | 5 #include "components/domain_reliability/util.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 | 13 |
14 namespace domain_reliability { | 14 namespace domain_reliability { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 class ActualTimer : public MockableTime::Timer { | 18 class ActualTimer : public MockableTime::Timer { |
19 public: | 19 public: |
20 // Initialize base timer with retain_user_info and is_repeating false. | 20 // Initialize base timer with retain_user_info and is_repeating false. |
21 ActualTimer() : base_timer_(false, false) {} | 21 ActualTimer() : base_timer_(false, false) {} |
22 | 22 |
23 virtual ~ActualTimer() {} | 23 ~ActualTimer() override {} |
24 | 24 |
25 // MockableTime::Timer implementation: | 25 // MockableTime::Timer implementation: |
26 virtual void Start(const tracked_objects::Location& posted_from, | 26 void Start(const tracked_objects::Location& posted_from, |
27 base::TimeDelta delay, | 27 base::TimeDelta delay, |
28 const base::Closure& user_task) override { | 28 const base::Closure& user_task) override { |
29 base_timer_.Start(posted_from, delay, user_task); | 29 base_timer_.Start(posted_from, delay, user_task); |
30 } | 30 } |
31 | 31 |
32 virtual void Stop() override { | 32 void Stop() override { base_timer_.Stop(); } |
33 base_timer_.Stop(); | |
34 } | |
35 | 33 |
36 virtual bool IsRunning() override { | 34 bool IsRunning() override { return base_timer_.IsRunning(); } |
37 return base_timer_.IsRunning(); | |
38 } | |
39 | 35 |
40 private: | 36 private: |
41 base::Timer base_timer_; | 37 base::Timer base_timer_; |
42 }; | 38 }; |
43 | 39 |
44 const struct NetErrorMapping { | 40 const struct NetErrorMapping { |
45 int net_error; | 41 int net_error; |
46 const char* beacon_status; | 42 const char* beacon_status; |
47 } net_error_map[] = { | 43 } net_error_map[] = { |
48 { net::OK, "ok" }, | 44 { net::OK, "ok" }, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ActualTime::~ActualTime() {} | 129 ActualTime::~ActualTime() {} |
134 | 130 |
135 base::Time ActualTime::Now() { return base::Time::Now(); } | 131 base::Time ActualTime::Now() { return base::Time::Now(); } |
136 base::TimeTicks ActualTime::NowTicks() { return base::TimeTicks::Now(); } | 132 base::TimeTicks ActualTime::NowTicks() { return base::TimeTicks::Now(); } |
137 | 133 |
138 scoped_ptr<MockableTime::Timer> ActualTime::CreateTimer() { | 134 scoped_ptr<MockableTime::Timer> ActualTime::CreateTimer() { |
139 return scoped_ptr<MockableTime::Timer>(new ActualTimer()); | 135 return scoped_ptr<MockableTime::Timer>(new ActualTimer()); |
140 } | 136 } |
141 | 137 |
142 } // namespace domain_reliability | 138 } // namespace domain_reliability |
OLD | NEW |