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

Unified Diff: third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h

Issue 2778743004: [scheduler] Refactor common code into BudgetPool. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h b/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h
index 187daccff5cca142c44519d22b2edfcc9811e6b4..de4f8ed77bbc5aca6e0d7cb1aad33da81384ceb6 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h
@@ -33,49 +33,59 @@ class BLINK_PLATFORM_EXPORT BudgetPool {
public:
virtual ~BudgetPool();
- virtual const char* Name() const = 0;
+ 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.
- virtual void AddQueue(base::TimeTicks now, TaskQueue* queue) = 0;
+ 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.
- virtual void RemoveQueue(base::TimeTicks now, TaskQueue* queue) = 0;
+ void RemoveQueue(base::TimeTicks now, TaskQueue* queue);
// Enables this time budget pool. Queues from this pool will be
// throttled based on their run time.
- virtual void EnableThrottling(LazyNow* now) = 0;
+ 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.
- virtual void DisableThrottling(LazyNow* now) = 0;
+ void DisableThrottling(LazyNow* now);
- virtual bool IsThrottlingEnabled() const = 0;
+ bool IsThrottlingEnabled() const;
- // Report task run time to the budget pool.
- virtual void RecordTaskRunTime(base::TimeTicks start_time,
- base::TimeTicks end_time) = 0;
+ // All queues should be removed before calling Close().
+ void Close();
// Block all associated queues and schedule them to run when appropriate.
- virtual void BlockThrottledQueues(base::TimeTicks now) = 0;
+ void BlockThrottledQueues(base::TimeTicks now);
- // All queues should be removed before calling Close().
- virtual void Close() = 0;
+ protected:
+ BudgetPool(const char* name, BudgetPoolController* budget_pool_controller);
- // Retuns earliest time (can be in the past) when the next task can run.
- virtual base::TimeTicks GetNextAllowedRunTime() = 0;
+ const char* name_; // NOT OWNED
- // Returns true at a task can be run immediately at the given time.
- virtual bool HasEnoughBudgetToRun(base::TimeTicks now) = 0;
+ BudgetPoolController* budget_pool_controller_;
- // Returns state for tracing.
- virtual void AsValueInto(base::trace_event::TracedValue* state,
- base::TimeTicks now) const = 0;
+ std::unordered_set<TaskQueue*> associated_task_queues_;
+ bool is_enabled_;
};
// CPUTimeBudgetPool represents a collection of task queues which share a limit
@@ -132,20 +142,12 @@ class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool {
base::Callback<void(base::TimeDelta)> reporting_callback);
// BudgetPool implementation:
- const char* Name() const override;
- void AddQueue(base::TimeTicks now, TaskQueue* queue) override;
- void RemoveQueue(base::TimeTicks now, TaskQueue* queue) override;
- void EnableThrottling(LazyNow* now) override;
- void DisableThrottling(LazyNow* now) override;
- bool IsThrottlingEnabled() const override;
void RecordTaskRunTime(base::TimeTicks start_time,
- base::TimeTicks end_time) override;
- void BlockThrottledQueues(base::TimeTicks now) override;
- void Close() override;
- bool HasEnoughBudgetToRun(base::TimeTicks now) override;
- base::TimeTicks GetNextAllowedRunTime() override;
+ base::TimeTicks end_time) final;
+ bool HasEnoughBudgetToRun(base::TimeTicks now) final;
+ base::TimeTicks GetNextAllowedRunTime() final;
void AsValueInto(base::trace_event::TracedValue* state,
- base::TimeTicks now) const override;
+ base::TimeTicks now) const final;
private:
FRIEND_TEST_ALL_PREFIXES(TaskQueueThrottlerTest, CPUTimeBudgetPool);
@@ -160,10 +162,6 @@ class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool {
// condition if necessary.
void EnforceBudgetLevelRestrictions();
- const char* name_; // NOT OWNED
-
- BudgetPoolController* budget_pool_controller_;
-
// Max budget level which we can accrue.
// Tasks will be allowed to run for this time before being throttled
// after a very long period of inactivity.
@@ -180,9 +178,6 @@ class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool {
base::TimeDelta current_budget_level_;
base::TimeTicks last_checkpoint_;
double cpu_percentage_;
- bool is_enabled_;
-
- std::unordered_set<TaskQueue*> associated_task_queues_;
base::Callback<void(base::TimeDelta)> reporting_callback_;
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698