Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 // Disables with time budget pool. Queues from this pool will not be | 78 // Disables with time budget pool. Queues from this pool will not be |
| 79 // throttled based on their run time. A call to |PumpThrottledTasks| | 79 // throttled based on their run time. A call to |PumpThrottledTasks| |
| 80 // will be scheduled to enable this queues back again and respect | 80 // will be scheduled to enable this queues back again and respect |
| 81 // timer alignment. Internal budget level will not regenerate with time. | 81 // timer alignment. Internal budget level will not regenerate with time. |
| 82 void DisableThrottling(LazyNow* now); | 82 void DisableThrottling(LazyNow* now); |
| 83 | 83 |
| 84 bool IsThrottlingEnabled() const; | 84 bool IsThrottlingEnabled() const; |
| 85 | 85 |
| 86 const char* Name() const; | 86 const char* Name() const; |
| 87 | 87 |
| 88 // Set callback which will be called every time when this budget pool | |
| 89 // is throttled. | |
|
Sami
2016/11/04 17:51:49
Please explain what value the callback is given to
alex clarke (OOO till 29th)
2016/11/07 16:53:10
+1 You could consider naming it here.
altimin
2016/11/07 17:25:30
Done.
| |
| 90 void SetReportingCallback( | |
| 91 base::Callback<void(base::TimeDelta)> reporting_callback); | |
| 92 | |
| 88 // All queues should be removed before calling Close(). | 93 // All queues should be removed before calling Close(). |
| 89 void Close(); | 94 void Close(); |
| 90 | 95 |
| 91 private: | 96 private: |
| 92 friend class TaskQueueThrottler; | 97 friend class TaskQueueThrottler; |
| 93 | 98 |
| 94 FRIEND_TEST_ALL_PREFIXES(TaskQueueThrottlerTest, TimeBudgetPool); | 99 FRIEND_TEST_ALL_PREFIXES(TaskQueueThrottlerTest, TimeBudgetPool); |
| 95 | 100 |
| 96 TimeBudgetPool(const char* name, | 101 TimeBudgetPool(const char* name, |
| 97 TaskQueueThrottler* task_queue_throttler, | 102 TaskQueueThrottler* task_queue_throttler, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 // that at least one task will be run every max_throttling_duration. | 139 // that at least one task will be run every max_throttling_duration. |
| 135 base::Optional<base::TimeDelta> max_throttling_duration_; | 140 base::Optional<base::TimeDelta> max_throttling_duration_; |
| 136 | 141 |
| 137 base::TimeDelta current_budget_level_; | 142 base::TimeDelta current_budget_level_; |
| 138 base::TimeTicks last_checkpoint_; | 143 base::TimeTicks last_checkpoint_; |
| 139 double cpu_percentage_; | 144 double cpu_percentage_; |
| 140 bool is_enabled_; | 145 bool is_enabled_; |
| 141 | 146 |
| 142 std::unordered_set<TaskQueue*> associated_task_queues_; | 147 std::unordered_set<TaskQueue*> associated_task_queues_; |
| 143 | 148 |
| 149 base::Optional<base::Callback<void(base::TimeDelta)>> reporting_callback_; | |
|
alex clarke (OOO till 29th)
2016/11/07 16:53:10
Do we really need base::Optional? base::Callback h
| |
| 150 | |
| 144 DISALLOW_COPY_AND_ASSIGN(TimeBudgetPool); | 151 DISALLOW_COPY_AND_ASSIGN(TimeBudgetPool); |
| 145 }; | 152 }; |
| 146 | 153 |
| 147 // TODO(altimin): Do not pass tracing category as const char*, | 154 // TODO(altimin): Do not pass tracing category as const char*, |
| 148 // hard-code string instead. | 155 // hard-code string instead. |
| 149 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler, | 156 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler, |
| 150 const char* tracing_category); | 157 const char* tracing_category); |
| 151 | 158 |
| 152 ~TaskQueueThrottler() override; | 159 ~TaskQueueThrottler() override; |
| 153 | 160 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 277 |
| 271 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; | 278 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; |
| 272 | 279 |
| 273 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); | 280 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); |
| 274 }; | 281 }; |
| 275 | 282 |
| 276 } // namespace scheduler | 283 } // namespace scheduler |
| 277 } // namespace blink | 284 } // namespace blink |
| 278 | 285 |
| 279 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_ | 286 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_ |
| OLD | NEW |