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

Side by Side Diff: components/domain_reliability/dispatcher.h

Issue 252613002: Domain Reliability: More security review. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 8 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
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 #ifndef COMPONENTS_DOMAIN_RELIABILITY_DISPATCHER_H_ 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_DISPATCHER_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_DISPATCHER_H_ 6 #define COMPONENTS_DOMAIN_RELIABILITY_DISPATCHER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
Ryan Sleevi 2014/04/26 02:37:39 IWYU: Unused
Deprecated (see juliatuttle) 2014/04/28 22:01:13 Done.
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/domain_reliability/domain_reliability_export.h" 13 #include "components/domain_reliability/domain_reliability_export.h"
14 #include "components/domain_reliability/util.h" 14 #include "components/domain_reliability/util.h"
15 15
16 namespace tracked_objects { 16 namespace tracked_objects {
17 class Location; 17 class Location;
18 } // namespace tracked_objects 18 } // namespace tracked_objects
19 19
20 namespace domain_reliability { 20 namespace domain_reliability {
21 21
22 // Runs tasks during a specified interval. Calling |RunEligibleTasks| gives any 22 // Runs tasks during a specified interval. Calling |RunEligibleTasks| gives any
23 // task a chance to run early (if the minimum delay has already passed); tasks 23 // task a chance to run early (if the minimum delay has already passed); tasks
24 // that aren't run early will be run once their maximum delay has passed. 24 // that aren't run early will be run once their maximum delay has passed.
25 // 25 //
26 // (See scheduler.h for an explanation of how the intervals are chosen.) 26 // (See scheduler.h for an explanation of how the intervals are chosen.)
27 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityDispatcher { 27 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityDispatcher {
28 public: 28 public:
29 DomainReliabilityDispatcher(MockableTime* time); 29 DomainReliabilityDispatcher(MockableTime* time);
Ryan Sleevi 2014/04/26 02:37:39 style: explicit
Deprecated (see juliatuttle) 2014/04/28 22:01:13 Done.
30 ~DomainReliabilityDispatcher(); 30 ~DomainReliabilityDispatcher();
31 31
32 void ScheduleTask( 32 void ScheduleTask(const base::Closure& task,
33 const base::Closure& task, 33 base::TimeDelta min_delay,
34 base::TimeDelta min_delay, 34 base::TimeDelta max_delay);
35 base::TimeDelta max_delay);
36 35
37 void RunEligibleTasks(); 36 void RunEligibleTasks();
38 37
39 private: 38 private:
40 struct Task { 39 struct Task {
41 Task(const base::Closure& closure_p, 40 Task(const base::Closure& closure_p,
42 scoped_ptr<MockableTime::Timer> timer_p, 41 scoped_ptr<MockableTime::Timer> timer_p,
Ryan Sleevi 2014/04/26 02:37:39 nit: What's up with the naming here? nit: You can
Deprecated (see juliatuttle) 2014/04/28 22:01:13 Sorry, that's an odd (and it turns out unnecessary
43 base::TimeDelta min_delay_p, 42 base::TimeDelta min_delay_p,
44 base::TimeDelta max_delay_p); 43 base::TimeDelta max_delay_p);
45 ~Task(); 44 ~Task();
46 45
47 base::Closure closure; 46 base::Closure closure;
48 scoped_ptr<MockableTime::Timer> timer; 47 scoped_ptr<MockableTime::Timer> timer;
49 base::TimeDelta min_delay; 48 base::TimeDelta min_delay;
50 base::TimeDelta max_delay; 49 base::TimeDelta max_delay;
51 bool eligible; 50 bool eligible;
52 }; 51 };
53 52
54 void MakeTaskWaiting(Task* task); 53 void MakeTaskWaiting(Task* task);
55 void MakeTaskEligible(Task* task); 54 void MakeTaskEligible(Task* task);
56 void RunAndDeleteTask(Task* task); 55 void RunAndDeleteTask(Task* task);
57 56
58 MockableTime* time_; 57 MockableTime* time_;
59 std::set<Task*> tasks_; 58 std::set<Task*> tasks_;
60 std::set<Task*> eligible_tasks_; 59 std::set<Task*> eligible_tasks_;
61 }; 60 };
62 61
63 } // namespace domain_reliability 62 } // namespace domain_reliability
64 63
65 #endif 64 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698