OLD | NEW |
| (Empty) |
1 // Copyright 2015 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. | |
4 | |
5 #ifndef COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ | |
6 #define COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ | |
7 | |
8 #include <set> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/scheduler/base/time_domain.h" | |
12 #include "components/scheduler/scheduler_export.h" | |
13 #include "third_party/WebKit/public/platform/WebViewScheduler.h" | |
14 | |
15 namespace scheduler { | |
16 | |
17 class RendererSchedulerImpl; | |
18 class VirtualTimeDomain; | |
19 class WebFrameSchedulerImpl; | |
20 | |
21 class SCHEDULER_EXPORT ThrottlingHelper : public TimeDomain::Observer { | |
22 public: | |
23 ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler, | |
24 const char* tracing_category); | |
25 | |
26 ~ThrottlingHelper() override; | |
27 | |
28 // TimeDomain::Observer implementation: | |
29 void OnTimeDomainHasImmediateWork() override; | |
30 void OnTimeDomainHasDelayedWork() override; | |
31 | |
32 void Throttle(TaskQueue* task_queue); | |
33 void Unthrottle(TaskQueue* task_queue); | |
34 | |
35 const VirtualTimeDomain* time_domain() const { return time_domain_.get(); } | |
36 | |
37 static base::TimeDelta DelayToNextRunTimeInSeconds(base::TimeTicks now); | |
38 | |
39 private: | |
40 void PumpThrottledTasks(); | |
41 void MaybeSchedulePumpThrottledTasksLocked(); | |
42 | |
43 std::set<TaskQueue*> throttled_queues_; | |
44 base::Closure pump_throttled_tasks_closure_; | |
45 base::Closure forward_immediate_work_closure_; | |
46 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
47 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED | |
48 base::TickClock* tick_clock_; // NOT OWNED | |
49 const char* tracing_category_; // NOT OWNED | |
50 scoped_ptr<VirtualTimeDomain> time_domain_; | |
51 | |
52 bool pending_pump_throttled_tasks_; | |
53 | |
54 base::WeakPtrFactory<ThrottlingHelper> weak_factory_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(ThrottlingHelper); | |
57 }; | |
58 | |
59 } // namespace scheduler | |
60 | |
61 #endif // COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ | |
OLD | NEW |