Linux: The App Launcher now appears on the "Internet" menu, not "Other".
[chromium-blink-merge.git] / components / domain_reliability / dispatcher.h
blob52309e7213e9de3fce1ceccb399371eaac2f2448
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_DISPATCHER_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_DISPATCHER_H_
8 #include <set>
10 #include "base/callback.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/time/time.h"
13 #include "components/domain_reliability/domain_reliability_export.h"
14 #include "components/domain_reliability/util.h"
16 namespace tracked_objects {
17 class Location;
18 } // namespace tracked_objects
20 namespace domain_reliability {
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
24 // that aren't run early will be run once their maximum delay has passed.
26 // (See scheduler.h for an explanation of how the intervals are chosen.)
27 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityDispatcher {
28 public:
29 DomainReliabilityDispatcher(MockableTime* time);
30 ~DomainReliabilityDispatcher();
32 void ScheduleTask(
33 const base::Closure& task,
34 base::TimeDelta min_delay,
35 base::TimeDelta max_delay);
37 void RunEligibleTasks();
39 private:
40 struct Task {
41 Task(const base::Closure& closure_p,
42 scoped_ptr<MockableTime::Timer> timer_p,
43 base::TimeDelta min_delay_p,
44 base::TimeDelta max_delay_p);
45 ~Task();
47 base::Closure closure;
48 scoped_ptr<MockableTime::Timer> timer;
49 base::TimeDelta min_delay;
50 base::TimeDelta max_delay;
51 bool eligible;
54 void MakeTaskWaiting(Task* task);
55 void MakeTaskEligible(Task* task);
56 void RunAndDeleteTask(Task* task);
58 MockableTime* time_;
59 std::set<Task*> tasks_;
60 std::set<Task*> eligible_tasks_;
63 } // namespace domain_reliability
65 #endif