| 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 "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "components/domain_reliability/scheduler.h" | 9 #include "components/domain_reliability/scheduler.h" |
| 10 #include "net/url_request/url_request_status.h" | 10 #include "net/url_request/url_request_status.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 callback_sequence_number_(0), | 22 callback_sequence_number_(0), |
| 23 weak_factory_(this) { | 23 weak_factory_(this) { |
| 24 DCHECK(time); | 24 DCHECK(time); |
| 25 } | 25 } |
| 26 | 26 |
| 27 virtual ~MockTimer() {} | 27 virtual ~MockTimer() {} |
| 28 | 28 |
| 29 // MockableTime::Timer implementation: | 29 // MockableTime::Timer implementation: |
| 30 virtual void Start(const tracked_objects::Location& posted_from, | 30 virtual void Start(const tracked_objects::Location& posted_from, |
| 31 base::TimeDelta delay, | 31 base::TimeDelta delay, |
| 32 const base::Closure& user_task) OVERRIDE { | 32 const base::Closure& user_task) override { |
| 33 DCHECK(!user_task.is_null()); | 33 DCHECK(!user_task.is_null()); |
| 34 | 34 |
| 35 if (running_) | 35 if (running_) |
| 36 ++callback_sequence_number_; | 36 ++callback_sequence_number_; |
| 37 running_ = true; | 37 running_ = true; |
| 38 user_task_ = user_task; | 38 user_task_ = user_task; |
| 39 time_->AddTask(delay, | 39 time_->AddTask(delay, |
| 40 base::Bind(&MockTimer::OnDelayPassed, | 40 base::Bind(&MockTimer::OnDelayPassed, |
| 41 weak_factory_.GetWeakPtr(), | 41 weak_factory_.GetWeakPtr(), |
| 42 callback_sequence_number_)); | 42 callback_sequence_number_)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual void Stop() OVERRIDE { | 45 virtual void Stop() override { |
| 46 if (running_) { | 46 if (running_) { |
| 47 ++callback_sequence_number_; | 47 ++callback_sequence_number_; |
| 48 running_ = false; | 48 running_ = false; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual bool IsRunning() OVERRIDE { return running_; } | 52 virtual bool IsRunning() override { return running_; } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 void OnDelayPassed(int expected_callback_sequence_number) { | 55 void OnDelayPassed(int expected_callback_sequence_number) { |
| 56 if (callback_sequence_number_ != expected_callback_sequence_number) | 56 if (callback_sequence_number_ != expected_callback_sequence_number) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 DCHECK(running_); | 59 DCHECK(running_); |
| 60 running_ = false; | 60 running_ = false; |
| 61 | 61 |
| 62 // Grab user task in case it re-entrantly starts the timer again. | 62 // Grab user task in case it re-entrantly starts the timer again. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 config->version = "1"; | 193 config->version = "1"; |
| 194 config->valid_until = 1234567890.0; | 194 config->valid_until = 1234567890.0; |
| 195 config->domain = domain; | 195 config->domain = domain; |
| 196 | 196 |
| 197 DCHECK(config->IsValid()); | 197 DCHECK(config->IsValid()); |
| 198 | 198 |
| 199 return scoped_ptr<const DomainReliabilityConfig>(config); | 199 return scoped_ptr<const DomainReliabilityConfig>(config); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace domain_reliability | 202 } // namespace domain_reliability |
| OLD | NEW |