| 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_TASK_QUEUE_THROTTL
ER_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THROTTL
ER_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THROTTL
ER_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THROTTL
ER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/optional.h" | 13 #include "base/optional.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "platform/PlatformExport.h" |
| 15 #include "platform/scheduler/base/cancelable_closure_holder.h" | 16 #include "platform/scheduler/base/cancelable_closure_holder.h" |
| 16 #include "platform/scheduler/base/time_domain.h" | 17 #include "platform/scheduler/base/time_domain.h" |
| 17 #include "platform/scheduler/renderer/budget_pool.h" | 18 #include "platform/scheduler/renderer/budget_pool.h" |
| 18 #include "platform/scheduler/renderer/web_view_scheduler.h" | 19 #include "platform/scheduler/renderer/web_view_scheduler.h" |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 namespace trace_event { | 22 namespace trace_event { |
| 22 class TracedValue; | 23 class TracedValue; |
| 23 } | 24 } |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace blink { | 27 namespace blink { |
| 27 namespace scheduler { | 28 namespace scheduler { |
| 28 | 29 |
| 29 class BudgetPool; | 30 class BudgetPool; |
| 30 class RendererSchedulerImpl; | 31 class RendererSchedulerImpl; |
| 31 class ThrottledTimeDomain; | 32 class ThrottledTimeDomain; |
| 32 class CPUTimeBudgetPool; | 33 class CPUTimeBudgetPool; |
| 33 | 34 |
| 34 // Interface for BudgetPool to interact with TaskQueueThrottler. | 35 // Interface for BudgetPool to interact with TaskQueueThrottler. |
| 35 class BLINK_PLATFORM_EXPORT BudgetPoolController { | 36 class PLATFORM_EXPORT BudgetPoolController { |
| 36 public: | 37 public: |
| 37 virtual ~BudgetPoolController() {} | 38 virtual ~BudgetPoolController() {} |
| 38 | 39 |
| 39 // To be used by BudgetPool only, use BudgetPool::{Add,Remove}Queue | 40 // To be used by BudgetPool only, use BudgetPool::{Add,Remove}Queue |
| 40 // methods instead. | 41 // methods instead. |
| 41 virtual void AddQueueToBudgetPool(TaskQueue* queue, | 42 virtual void AddQueueToBudgetPool(TaskQueue* queue, |
| 42 BudgetPool* budget_pool) = 0; | 43 BudgetPool* budget_pool) = 0; |
| 43 virtual void RemoveQueueFromBudgetPool(TaskQueue* queue, | 44 virtual void RemoveQueueFromBudgetPool(TaskQueue* queue, |
| 44 BudgetPool* budget_pool) = 0; | 45 BudgetPool* budget_pool) = 0; |
| 45 | 46 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 73 // policy reasons. To prevent the systems from fighting, clients of | 74 // policy reasons. To prevent the systems from fighting, clients of |
| 74 // TaskQueueThrottler must use SetQueueEnabled rather than calling the function | 75 // TaskQueueThrottler must use SetQueueEnabled rather than calling the function |
| 75 // directly on the queue. | 76 // directly on the queue. |
| 76 // | 77 // |
| 77 // There may be more than one system that wishes to throttle a queue (e.g. | 78 // There may be more than one system that wishes to throttle a queue (e.g. |
| 78 // renderer suspension vs tab level suspension) so the TaskQueueThrottler keeps | 79 // renderer suspension vs tab level suspension) so the TaskQueueThrottler keeps |
| 79 // a count of the number of systems that wish a queue to be throttled. | 80 // a count of the number of systems that wish a queue to be throttled. |
| 80 // See IncreaseThrottleRefCount & DecreaseThrottleRefCount. | 81 // See IncreaseThrottleRefCount & DecreaseThrottleRefCount. |
| 81 // | 82 // |
| 82 // This class is main-thread only. | 83 // This class is main-thread only. |
| 83 class BLINK_PLATFORM_EXPORT TaskQueueThrottler : public TaskQueue::Observer, | 84 class PLATFORM_EXPORT TaskQueueThrottler : public TaskQueue::Observer, |
| 84 public BudgetPoolController { | 85 public BudgetPoolController { |
| 85 public: | 86 public: |
| 86 // TODO(altimin): Do not pass tracing category as const char*, | 87 // TODO(altimin): Do not pass tracing category as const char*, |
| 87 // hard-code string instead. | 88 // hard-code string instead. |
| 88 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler, | 89 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler, |
| 89 const char* tracing_category); | 90 const char* tracing_category); |
| 90 | 91 |
| 91 ~TaskQueueThrottler() override; | 92 ~TaskQueueThrottler() override; |
| 92 | 93 |
| 93 // TaskQueue::Observer implementation: | 94 // TaskQueue::Observer implementation: |
| 94 void OnQueueNextWakeUpChanged(TaskQueue* queue, | 95 void OnQueueNextWakeUpChanged(TaskQueue* queue, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 191 |
| 191 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; | 192 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; |
| 192 | 193 |
| 193 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); | 194 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); |
| 194 }; | 195 }; |
| 195 | 196 |
| 196 } // namespace scheduler | 197 } // namespace scheduler |
| 197 } // namespace blink | 198 } // namespace blink |
| 198 | 199 |
| 199 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THRO
TTLER_H_ | 200 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THRO
TTLER_H_ |
| OLD | NEW |