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

Side by Side Diff: components/scheduler/renderer/throttling_helper.h

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years 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
(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 void Unregister(TaskQueue* task_queue);
35
36 const scoped_refptr<VirtualTimeDomain>& time_domain() const {
37 return time_domain_;
38 }
39
40 static base::TimeDelta DelayToNextRunTimeInSeconds(base::TimeTicks now);
41
42 private:
43 void PumpThrottledTasks();
44 void MaybeSchedulePumpThrottledTasksLocked();
45
46 std::set<TaskQueue*> throttled_queues_;
47 base::Closure pump_throttled_tasks_closure_;
48 base::Closure forward_immediate_work_closure_;
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
50 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED
51 base::TickClock* tick_clock_; // NOT OWNED
52 const char* tracing_category_; // NOT OWNED
53 scoped_refptr<VirtualTimeDomain> time_domain_;
54
55 bool pending_pump_throttled_tasks_;
56 bool work_to_do_;
57
58 base::WeakPtrFactory<ThrottlingHelper> weak_factory_;
59
60 DISALLOW_COPY_AND_ASSIGN(ThrottlingHelper);
61 };
62
63 } // namespace scheduler
64
65 #endif // COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698