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

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

Issue 2778123003: [scheduler] Add WakeupBudgetPool. (Closed)
Patch Set: Addressed comments Created 3 years, 7 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/wake_up_budget_pool.h
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/wake_up_budget_pool.h b/third_party/WebKit/Source/platform/scheduler/renderer/wake_up_budget_pool.h
new file mode 100644
index 0000000000000000000000000000000000000000..26ab1f26d2e651060ed0d708dc51e78ff9828e23
--- /dev/null
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/wake_up_budget_pool.h
@@ -0,0 +1,66 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// 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_WAKE_UP_BUDGET_POOL_H_
+#define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_WAKE_UP_BUDGET_POOL_H_
+
+#include "platform/scheduler/renderer/budget_pool.h"
+
+#include "base/macros.h"
+#include "base/optional.h"
+#include "base/time/time.h"
+#include "platform/scheduler/base/lazy_now.h"
+
+namespace blink {
+namespace scheduler {
+
+// WakeUpBudgetPool represents a collection of task queues which share a limit
+// on total cpu time.
+class PLATFORM_EXPORT WakeUpBudgetPool : public BudgetPool {
+ public:
+ WakeUpBudgetPool(const char* name,
+ BudgetPoolController* budget_pool_controller,
+ base::TimeTicks now);
+ ~WakeUpBudgetPool() override;
+
+ // Note: this does not have an immediate effect and should be called only
+ // during initialization of a WakeUpBudgetPool.
+ void SetWakeUpRate(double wakeups_per_second);
+
+ // Note: this does not have an immediate effect and should be called only
+ // during initialization of a WakeUpBudgetPool.
+ void SetWakeUpDuration(base::TimeDelta duration);
+
+ // BudgetPool implementation:
+ void RecordTaskRunTime(TaskQueue* queue,
+ base::TimeTicks start_time,
+ base::TimeTicks end_time) final;
+ bool CanRunTasksAt(base::TimeTicks moment, 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:
+ base::Optional<base::TimeTicks> NextWakeUp() const;
+
+ double wakeups_per_second_;
+ base::TimeDelta wakeup_duration_;
+
+ base::Optional<base::TimeTicks> last_wakeup_;
+
+ DISALLOW_COPY_AND_ASSIGN(WakeUpBudgetPool);
+};
+
+} // namespace scheduler
+} // namespace blink
+
+#endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_WAKE_UP_BUDGET_POOL_H_

Powered by Google App Engine
This is Rietveld 408576698