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

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 from alexclarke@ 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 BLINK_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 CanRunTasksUntil(base::TimeTicks now,
40 base::TimeTicks moment) const final;
41 bool CanRunTasksAt(base::TimeTicks now, bool is_wake_up) const final;
42 base::TimeTicks GetNextAllowedRunTime(
43 base::TimeTicks desired_run_time) const final;
44 void OnQueueNextWakeUpChanged(TaskQueue* queue,
45 base::TimeTicks now,
46 base::TimeTicks desired_run_time) final;
47 void OnWakeUp(base::TimeTicks now) final;
48 void AsValueInto(base::trace_event::TracedValue* state,
49 base::TimeTicks now) const final;
50
51 protected:
52 QueueBlockType GetBlockType() const final;
53
54 private:
55 base::Optional<base::TimeTicks> NextWakeUp() const;
56
57 double wakeups_per_second_;
58 base::TimeDelta wakeup_duration_;
59
60 base::Optional<base::TimeTicks> last_wakeup_;
61
62 DISALLOW_COPY_AND_ASSIGN(WakeUpBudgetPool);
63 };
64
65 } // namespace scheduler
66 } // namespace blink
67
68 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_WAKE_UP_BUDGET_ POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698