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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_WAKE_UP_BUDGET_POO L_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_WAKE_UP_BUDGET_POO L_H_
7
8 #include "platform/scheduler/renderer/budget_pool.h"
9
10 #include "base/macros.h"
11 #include "base/optional.h"
12 #include "base/time/time.h"
13 #include "platform/scheduler/base/lazy_now.h"
14
15 namespace blink {
16 namespace scheduler {
17
18 // WakeUpBudgetPool represents a collection of task queues which share a limit
19 // on total cpu time.
20 class PLATFORM_EXPORT WakeUpBudgetPool : public BudgetPool {
21 public:
22 WakeUpBudgetPool(const char* name,
23 BudgetPoolController* budget_pool_controller,
24 base::TimeTicks now);
25 ~WakeUpBudgetPool() override;
26
27 // Note: this does not have an immediate effect and should be called only
28 // during initialization of a WakeUpBudgetPool.
29 void SetWakeUpRate(double wakeups_per_second);
30
31 // Note: this does not have an immediate effect and should be called only
32 // during initialization of a WakeUpBudgetPool.
33 void SetWakeUpDuration(base::TimeDelta duration);
34
35 // BudgetPool implementation:
36 void RecordTaskRunTime(TaskQueue* queue,
37 base::TimeTicks start_time,
38 base::TimeTicks end_time) final;
39 bool CanRunTasksAt(base::TimeTicks moment, bool is_wake_up) const final;
40 base::TimeTicks GetNextAllowedRunTime(
41 base::TimeTicks desired_run_time) const final;
42 void OnQueueNextWakeUpChanged(TaskQueue* queue,
43 base::TimeTicks now,
44 base::TimeTicks desired_run_time) final;
45 void OnWakeUp(base::TimeTicks now) final;
46 void AsValueInto(base::trace_event::TracedValue* state,
47 base::TimeTicks now) const final;
48
49 protected:
50 QueueBlockType GetBlockType() const final;
51
52 private:
53 base::Optional<base::TimeTicks> NextWakeUp() const;
54
55 double wakeups_per_second_;
56 base::TimeDelta wakeup_duration_;
57
58 base::Optional<base::TimeTicks> last_wakeup_;
59
60 DISALLOW_COPY_AND_ASSIGN(WakeUpBudgetPool);
61 };
62
63 } // namespace scheduler
64 } // namespace blink
65
66 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_WAKE_UP_BUDGET_ POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698