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

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

Issue 2742383005: [scheduler] Untangle BudgetPool from TaskQueueThrottler. (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
Index: third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.h
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.h b/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.h
index 6e5014cdf7ac43cc1f9ecb050e2b3b34cbe50d44..86bf51a8712f5d5ed805bc06ab19017e23517622 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.h
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.h
@@ -109,16 +109,33 @@ class BLINK_PLATFORM_EXPORT TaskQueueThrottler : public TimeDomain::Observer {
void AsValueInto(base::trace_event::TracedValue* state,
base::TimeTicks now) const;
- private:
- friend class BudgetPool;
- friend class CPUTimeBudgetPool;
+ // Methods for BudgetPools to interact with TaskQueueThrottler.
+
+ // To be used by BudgetPool only, use BudgetPool::{Add,Remove}Queue
+ // methods instead.
+ void AddQueueToBudgetPool(TaskQueue* queue, BudgetPool* budget_pool);
alex clarke (OOO till 29th) 2017/03/14 18:22:39 bike-shed: Should we try to decouple even further
altimin 2017/03/14 18:26:44 I like the idea in general, but that I think that'
Sami 2017/03/14 18:43:01 I think I'd also like to suggest turning these met
altimin 2017/03/14 20:04:28 Done.
+ void RemoveQueueFromBudgetPool(TaskQueue* queue, BudgetPool* budget_pool);
+
+ // Deletes the budget pool.
+ void UnregisterBudgetPool(BudgetPool* budget_pool);
+
+ // Schedule a call to PumpThrottledTasks to unblock a queue at an appropriate
+ // moment.
+ void SchedulePumpQueue(const tracked_objects::Location& from_here,
+ base::TimeTicks now,
+ TaskQueue* queue);
+
+ // Insert a fence to prevent tasks from running and schedule a wakeup at
+ // an appropriate time.
+ void BlockThrottledQueue(base::TimeTicks now, TaskQueue* queue);
+ private:
struct Metadata {
- Metadata() : throttling_ref_count(0), time_budget_pool(nullptr) {}
+ Metadata() : throttling_ref_count(0), budget_pool(nullptr) {}
size_t throttling_ref_count;
- CPUTimeBudgetPool* time_budget_pool;
+ BudgetPool* budget_pool;
};
using TaskQueueMap = std::unordered_map<TaskQueue*, Metadata>;
@@ -132,14 +149,7 @@ class BLINK_PLATFORM_EXPORT TaskQueueThrottler : public TimeDomain::Observer {
base::TimeTicks now,
base::TimeTicks runtime);
- CPUTimeBudgetPool* GetTimeBudgetPoolForQueue(TaskQueue* queue);
-
- // Schedule pumping because of given task queue.
- void MaybeSchedulePumpQueue(
- const tracked_objects::Location& from_here,
- base::TimeTicks now,
- TaskQueue* queue,
- base::Optional<base::TimeTicks> next_possible_run_time);
+ BudgetPool* GetBudgetPoolForQueue(TaskQueue* queue);
// Return next possible time when queue is allowed to run in accordance
// with throttling policy.
@@ -159,8 +169,7 @@ class BLINK_PLATFORM_EXPORT TaskQueueThrottler : public TimeDomain::Observer {
base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_;
bool allow_throttling_;
- std::unordered_map<BudgetPool*, std::unique_ptr<BudgetPool>>
- time_budget_pools_;
+ std::unordered_map<BudgetPool*, std::unique_ptr<BudgetPool>> budget_pools_;
base::WeakPtrFactory<TaskQueueThrottler> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698