| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // TimeBudgetPool represents a group of task queues which share a limit | 49 // TimeBudgetPool represents a group of task queues which share a limit |
| 50 // on execution time. This limit applies when task queues are already | 50 // on execution time. This limit applies when task queues are already |
| 51 // throttled by TaskQueueThrottler. | 51 // throttled by TaskQueueThrottler. |
| 52 class BLINK_PLATFORM_EXPORT TimeBudgetPool { | 52 class BLINK_PLATFORM_EXPORT TimeBudgetPool { |
| 53 public: | 53 public: |
| 54 ~TimeBudgetPool(); | 54 ~TimeBudgetPool(); |
| 55 | 55 |
| 56 // Throttle task queues from this time budget pool if tasks are running | 56 // Throttle task queues from this time budget pool if tasks are running |
| 57 // for more than |cpu_percentage| per cent of wall time. | 57 // for more than |cpu_percentage| per cent of wall time. |
| 58 // This function does not affect internal time budget level. | 58 // This function does not affect internal time budget level. |
| 59 void SetTimeBudget(base::TimeTicks now, double cpu_percentage); | 59 void SetTimeBudgetRecoveryRate(base::TimeTicks now, double cpu_percentage); |
| 60 | 60 |
| 61 // Adds |queue| to given pool. If the pool restriction does not allow | 61 // Adds |queue| to given pool. If the pool restriction does not allow |
| 62 // a task to be run immediately and |queue| is throttled, |queue| becomes | 62 // a task to be run immediately and |queue| is throttled, |queue| becomes |
| 63 // disabled. | 63 // disabled. |
| 64 void AddQueue(base::TimeTicks now, TaskQueue* queue); | 64 void AddQueue(base::TimeTicks now, TaskQueue* queue); |
| 65 | 65 |
| 66 // Removes |queue| from given pool. If it is throttled, it does not | 66 // Removes |queue| from given pool. If it is throttled, it does not |
| 67 // become enabled immediately, but a call to |PumpThrottledTasks| | 67 // become enabled immediately, but a call to |PumpThrottledTasks| |
| 68 // is scheduled. | 68 // is scheduled. |
| 69 void RemoveQueue(base::TimeTicks now, TaskQueue* queue); | 69 void RemoveQueue(base::TimeTicks now, TaskQueue* queue); |
| 70 | 70 |
| 71 void RecordTaskRunTime(base::TimeTicks start_time, | 71 void RecordTaskRunTime(base::TimeTicks start_time, |
| 72 base::TimeTicks end_time); | 72 base::TimeTicks end_time); |
| 73 | 73 |
| 74 // Enables this time budget pool. Queues from this pool will be | 74 // Enables this time budget pool. Queues from this pool will be |
| 75 // throttled based on their run time. | 75 // throttled based on their run time. |
| 76 void EnableThrottling(LazyNow* now); | 76 void EnableThrottling(LazyNow* now); |
| 77 | 77 |
| 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 // Increase budget level by given value. This function DOES NOT unblock |
| 87 // queues even if they are allowed to run with increased budget level. |
| 88 void GrantAdditionalBudget(base::TimeTicks now, |
| 89 base::TimeDelta budget_level); |
| 90 |
| 86 const char* Name() const; | 91 const char* Name() const; |
| 87 | 92 |
| 88 // Set callback which will be called every time when this budget pool | 93 // Set callback which will be called every time when this budget pool |
| 89 // is throttled. Throttling duration (time until the queue is allowed | 94 // is throttled. Throttling duration (time until the queue is allowed |
| 90 // to run again) is passed as a parameter to callback. | 95 // to run again) is passed as a parameter to callback. |
| 91 void SetReportingCallback( | 96 void SetReportingCallback( |
| 92 base::Callback<void(base::TimeDelta)> reporting_callback); | 97 base::Callback<void(base::TimeDelta)> reporting_callback); |
| 93 | 98 |
| 94 // All queues should be removed before calling Close(). | 99 // All queues should be removed before calling Close(). |
| 95 void Close(); | 100 void Close(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 283 |
| 279 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; | 284 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; |
| 280 | 285 |
| 281 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); | 286 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); |
| 282 }; | 287 }; |
| 283 | 288 |
| 284 } // namespace scheduler | 289 } // namespace scheduler |
| 285 } // namespace blink | 290 } // namespace blink |
| 286 | 291 |
| 287 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP
ER_H_ | 292 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP
ER_H_ |
| OLD | NEW |