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/dispatcher.h" | 5 #include "components/domain_reliability/dispatcher.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 max_delay(max_delay), | 40 max_delay(max_delay), |
41 eligible(false) {} | 41 eligible(false) {} |
42 | 42 |
43 DomainReliabilityDispatcher::Task::~Task() {} | 43 DomainReliabilityDispatcher::Task::~Task() {} |
44 | 44 |
45 DomainReliabilityDispatcher::DomainReliabilityDispatcher(MockableTime* time) | 45 DomainReliabilityDispatcher::DomainReliabilityDispatcher(MockableTime* time) |
46 : time_(time) {} | 46 : time_(time) {} |
47 | 47 |
48 DomainReliabilityDispatcher::~DomainReliabilityDispatcher() { | 48 DomainReliabilityDispatcher::~DomainReliabilityDispatcher() { |
49 // TODO(juliatuttle): STLElementDeleter? | 49 // TODO(juliatuttle): STLElementDeleter? |
50 STLDeleteElements(&tasks_); | 50 base::STLDeleteElements(&tasks_); |
51 } | 51 } |
52 | 52 |
53 void DomainReliabilityDispatcher::ScheduleTask( | 53 void DomainReliabilityDispatcher::ScheduleTask( |
54 const base::Closure& closure, | 54 const base::Closure& closure, |
55 base::TimeDelta min_delay, | 55 base::TimeDelta min_delay, |
56 base::TimeDelta max_delay) { | 56 base::TimeDelta max_delay) { |
57 DCHECK(!closure.is_null()); | 57 DCHECK(!closure.is_null()); |
58 // Would be DCHECK_LE, but you can't << a TimeDelta. | 58 // Would be DCHECK_LE, but you can't << a TimeDelta. |
59 DCHECK(min_delay <= max_delay); | 59 DCHECK(min_delay <= max_delay); |
60 | 60 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 DCHECK(task); | 111 DCHECK(task); |
112 DCHECK(!task->closure.is_null()); | 112 DCHECK(!task->closure.is_null()); |
113 task->closure.Run(); | 113 task->closure.Run(); |
114 if (task->eligible) | 114 if (task->eligible) |
115 eligible_tasks_.erase(task); | 115 eligible_tasks_.erase(task); |
116 tasks_.erase(task); | 116 tasks_.erase(task); |
117 delete task; | 117 delete task; |
118 } | 118 } |
119 | 119 |
120 } // namespace domain_reliability | 120 } // namespace domain_reliability |
OLD | NEW |