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

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

Issue 1718233002: Fix computation of runtime for throttled tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 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 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_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ 5 #ifndef COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
6 #define COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ 6 #define COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/scheduler/base/cancelable_closure_holder.h" 11 #include "components/scheduler/base/cancelable_closure_holder.h"
12 #include "components/scheduler/base/time_domain.h" 12 #include "components/scheduler/base/time_domain.h"
13 #include "components/scheduler/scheduler_export.h" 13 #include "components/scheduler/scheduler_export.h"
14 #include "third_party/WebKit/public/platform/WebViewScheduler.h" 14 #include "third_party/WebKit/public/platform/WebViewScheduler.h"
15 15
16 namespace scheduler { 16 namespace scheduler {
17 17
18 class RendererSchedulerImpl; 18 class RendererSchedulerImpl;
19 class VirtualTimeDomain; 19 class ThrottledTimeDomain;
20 class WebFrameSchedulerImpl; 20 class WebFrameSchedulerImpl;
21 21
22 class SCHEDULER_EXPORT ThrottlingHelper : public TimeDomain::Observer { 22 class SCHEDULER_EXPORT ThrottlingHelper : public TimeDomain::Observer {
23 public: 23 public:
24 ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler, 24 ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler,
25 const char* tracing_category); 25 const char* tracing_category);
26 26
27 ~ThrottlingHelper() override; 27 ~ThrottlingHelper() override;
28 28
29 // TimeDomain::Observer implementation: 29 // TimeDomain::Observer implementation:
30 void OnTimeDomainHasImmediateWork() override; 30 void OnTimeDomainHasImmediateWork() override;
31 void OnTimeDomainHasDelayedWork() override; 31 void OnTimeDomainHasDelayedWork() override;
32 32
33 // Increments the throttled refcount and causes |task_queue| to be throttled 33 // Increments the throttled refcount and causes |task_queue| to be throttled
34 // if its not already throttled. 34 // if its not already throttled.
35 void IncreaseThrottleRefCount(TaskQueue* task_queue); 35 void IncreaseThrottleRefCount(TaskQueue* task_queue);
36 36
37 // If the refcouint is non-zero it's decremented. If the throttled refcount 37 // If the refcouint is non-zero it's decremented. If the throttled refcount
38 // becomes zero then |task_queue| is unthrottled. If the refcount was already 38 // becomes zero then |task_queue| is unthrottled. If the refcount was already
39 // zero this function does nothing. 39 // zero this function does nothing.
40 void DecreaseThrottleRefCount(TaskQueue* task_queue); 40 void DecreaseThrottleRefCount(TaskQueue* task_queue);
41 41
42 // Removes |task_queue| from |throttled_queues_|. 42 // Removes |task_queue| from |throttled_queues_|.
43 void UnregisterTaskQueue(TaskQueue* task_queue); 43 void UnregisterTaskQueue(TaskQueue* task_queue);
44 44
45 const VirtualTimeDomain* time_domain() const { return time_domain_.get(); } 45 const ThrottledTimeDomain* time_domain() const { return time_domain_.get(); }
46 46
47 static base::TimeTicks ThrottledRunTime(base::TimeTicks unthrottled_runtime); 47 static base::TimeTicks ThrottledRunTime(base::TimeTicks unthrottled_runtime);
48 48
49 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; } 49 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; }
50 50
51 private: 51 private:
52 using TaskQueueMap = std::map<TaskQueue*, size_t>; 52 using TaskQueueMap = std::map<TaskQueue*, size_t>;
53 53
54 void PumpThrottledTasks(); 54 void PumpThrottledTasks();
55 55
56 // Note |unthrottled_runtime| might be in the past. When this happens we 56 // Note |unthrottled_runtime| might be in the past. When this happens we
57 // compute the delay to the next runtime based on now rather than 57 // compute the delay to the next runtime based on now rather than
58 // unthrottled_runtime. 58 // unthrottled_runtime.
59 void MaybeSchedulePumpThrottledTasksLocked( 59 void MaybeSchedulePumpThrottledTasksLocked(
60 const tracked_objects::Location& from_here, 60 const tracked_objects::Location& from_here,
61 base::TimeTicks now, 61 base::TimeTicks now,
62 base::TimeTicks unthrottled_runtime); 62 base::TimeTicks unthrottled_runtime);
63 63
64 TaskQueueMap throttled_queues_; 64 TaskQueueMap throttled_queues_;
65 base::Closure forward_immediate_work_closure_; 65 base::Closure forward_immediate_work_closure_;
66 scoped_refptr<TaskQueue> task_runner_; 66 scoped_refptr<TaskQueue> task_runner_;
67 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED 67 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED
68 base::TickClock* tick_clock_; // NOT OWNED 68 base::TickClock* tick_clock_; // NOT OWNED
69 const char* tracing_category_; // NOT OWNED 69 const char* tracing_category_; // NOT OWNED
70 scoped_ptr<VirtualTimeDomain> time_domain_; 70 scoped_ptr<ThrottledTimeDomain> time_domain_;
71 71
72 CancelableClosureHolder suspend_timers_when_backgrounded_closure_; 72 CancelableClosureHolder suspend_timers_when_backgrounded_closure_;
73 base::TimeTicks pending_pump_throttled_tasks_runtime_; 73 base::TimeTicks pending_pump_throttled_tasks_runtime_;
74 74
75 base::WeakPtrFactory<ThrottlingHelper> weak_factory_; 75 base::WeakPtrFactory<ThrottlingHelper> weak_factory_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(ThrottlingHelper); 77 DISALLOW_COPY_AND_ASSIGN(ThrottlingHelper);
78 }; 78 };
79 79
80 } // namespace scheduler 80 } // namespace scheduler
81 81
82 #endif // COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ 82 #endif // COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
OLDNEW
« no previous file with comments | « components/scheduler/renderer/throttled_time_domain.cc ('k') | components/scheduler/renderer/throttling_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698