Index: third_party/WebKit/Source/platform/scheduler/renderer/cpu_time_budget_pool.h |
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h b/third_party/WebKit/Source/platform/scheduler/renderer/cpu_time_budget_pool.h |
similarity index 63% |
copy from third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h |
copy to third_party/WebKit/Source/platform/scheduler/renderer/cpu_time_budget_pool.h |
index 9bcb72a6d65560b974d1c9330cd3a7d01a79cff8..9a03c25555832c61c727faa60a1778b03e347a70 100644 |
--- a/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h |
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/cpu_time_budget_pool.h |
@@ -2,92 +2,20 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ |
-#define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ |
+#ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_CPU_TIME_BUDGET_POOL_H_ |
+#define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_CPU_TIME_BUDGET_POOL_H_ |
-#include <unordered_set> |
+#include "platform/scheduler/renderer/budget_pool.h" |
-#include "base/callback.h" |
#include "base/gtest_prod_util.h" |
#include "base/macros.h" |
#include "base/optional.h" |
#include "base/time/time.h" |
#include "platform/scheduler/base/lazy_now.h" |
-namespace base { |
-namespace trace_event { |
-class TracedValue; |
-} |
-} |
- |
namespace blink { |
namespace scheduler { |
-class TaskQueue; |
-class BudgetPoolController; |
- |
-// BudgetPool represents a group of task queues which share a limit |
-// on a resource. This limit applies when task queues are already throttled |
-// by TaskQueueThrottler. |
-class BLINK_PLATFORM_EXPORT BudgetPool { |
- public: |
- virtual ~BudgetPool(); |
- |
- const char* Name() const; |
- |
- // Report task run time to the budget pool. |
- virtual void RecordTaskRunTime(base::TimeTicks start_time, |
- base::TimeTicks end_time) = 0; |
- |
- // Retuns earliest time (can be in the past) when the next task can run. |
- virtual base::TimeTicks GetNextAllowedRunTime() = 0; |
- |
- // Returns true at a task can be run immediately at the given time. |
- virtual bool HasEnoughBudgetToRun(base::TimeTicks now) = 0; |
- |
- // Returns state for tracing. |
- virtual void AsValueInto(base::trace_event::TracedValue* state, |
- base::TimeTicks now) const = 0; |
- |
- // Adds |queue| to given pool. If the pool restriction does not allow |
- // a task to be run immediately and |queue| is throttled, |queue| becomes |
- // disabled. |
- void AddQueue(base::TimeTicks now, TaskQueue* queue); |
- |
- // Removes |queue| from given pool. If it is throttled, it does not |
- // become enabled immediately, but a call to |PumpThrottledTasks| |
- // is scheduled. |
- void RemoveQueue(base::TimeTicks now, TaskQueue* queue); |
- |
- // Enables this time budget pool. Queues from this pool will be |
- // throttled based on their run time. |
- void EnableThrottling(LazyNow* now); |
- |
- // Disables with time budget pool. Queues from this pool will not be |
- // throttled based on their run time. A call to |PumpThrottledTasks| |
- // will be scheduled to enable this queues back again and respect |
- // timer alignment. Internal budget level will not regenerate with time. |
- void DisableThrottling(LazyNow* now); |
- |
- bool IsThrottlingEnabled() const; |
- |
- // All queues should be removed before calling Close(). |
- void Close(); |
- |
- // Block all associated queues and schedule them to run when appropriate. |
- void BlockThrottledQueues(base::TimeTicks now); |
- |
- protected: |
- BudgetPool(const char* name, BudgetPoolController* budget_pool_controller); |
- |
- const char* name_; // NOT OWNED |
- |
- BudgetPoolController* budget_pool_controller_; |
- |
- std::unordered_set<TaskQueue*> associated_task_queues_; |
- bool is_enabled_; |
-}; |
- |
// CPUTimeBudgetPool represents a collection of task queues which share a limit |
// on total cpu time. |
class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool { |
@@ -142,13 +70,23 @@ class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool { |
base::Callback<void(base::TimeDelta)> reporting_callback); |
// BudgetPool implementation: |
- void RecordTaskRunTime(base::TimeTicks start_time, |
+ void RecordTaskRunTime(TaskQueue* queue, |
+ base::TimeTicks start_time, |
base::TimeTicks end_time) final; |
- bool HasEnoughBudgetToRun(base::TimeTicks now) final; |
- base::TimeTicks GetNextAllowedRunTime() final; |
+ bool CanRunTasksUntil(base::TimeTicks now, base::TimeTicks until) const final; |
+ bool CanRunTasksAt(base::TimeTicks now, bool is_wake_up) const final; |
+ base::TimeTicks GetNextAllowedRunTime( |
+ base::TimeTicks desired_run_time) const final; |
+ void OnQueueNextWakeUpChanged(TaskQueue* queue, |
+ base::TimeTicks now, |
+ base::TimeTicks desired_run_time) final; |
+ void OnWakeUp(base::TimeTicks now) final; |
void AsValueInto(base::trace_event::TracedValue* state, |
base::TimeTicks now) const final; |
+ protected: |
+ QueueBlockType GetBlockType() const final; |
+ |
private: |
FRIEND_TEST_ALL_PREFIXES(TaskQueueThrottlerTest, CPUTimeBudgetPool); |
@@ -187,4 +125,4 @@ class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool { |
} // namespace scheduler |
} // namespace blink |
-#endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_BUDGET_POOL_H_ |
+#endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_CPU_TIME_BUDGET_POOL_H_ |