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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/time_domain.h

Issue 2258133002: [scheduler] Implement time-based cpu throttling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more fix Created 4 years, 3 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 28 matching lines...) Expand all
39 // The clock itself is provided by subclasses of the TimeDomain and it may be 39 // The clock itself is provided by subclasses of the TimeDomain and it may be
40 // the real wall clock or a synthetic (virtual) time base. 40 // the real wall clock or a synthetic (virtual) time base.
41 class BLINK_PLATFORM_EXPORT TimeDomain { 41 class BLINK_PLATFORM_EXPORT TimeDomain {
42 public: 42 public:
43 class BLINK_PLATFORM_EXPORT Observer { 43 class BLINK_PLATFORM_EXPORT Observer {
44 public: 44 public:
45 virtual ~Observer() {} 45 virtual ~Observer() {}
46 46
47 // Called when an empty TaskQueue registered with this TimeDomain has a task 47 // Called when an empty TaskQueue registered with this TimeDomain has a task
48 // enqueued. 48 // enqueued.
49 virtual void OnTimeDomainHasImmediateWork() = 0; 49 // |task_queue| - task queue which has immediate work scheduled.
50 virtual void OnTimeDomainHasImmediateWork(TaskQueue* task_queue) = 0;
50 51
51 // Called when a TaskQueue registered with this TimeDomain has a delayed 52 // Called when a TaskQueue registered with this TimeDomain has a delayed
52 // task enqueued. 53 // task enqueued.
53 virtual void OnTimeDomainHasDelayedWork() = 0; 54 // |task_queue| - task queue which has delayed work scheduled.
55 virtual void OnTimeDomainHasDelayedWork(TaskQueue* task_queue) = 0;
54 }; 56 };
55 57
56 explicit TimeDomain(Observer* observer); 58 explicit TimeDomain(Observer* observer);
57 virtual ~TimeDomain(); 59 virtual ~TimeDomain();
58 60
59 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from 61 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from
60 // any thread. 62 // any thread.
61 // TODO(alexclarke): Make this main thread only. 63 // TODO(alexclarke): Make this main thread only.
62 virtual LazyNow CreateLazyNow() const = 0; 64 virtual LazyNow CreateLazyNow() const = 0;
63 65
(...skipping 11 matching lines...) Expand all
75 // runtime for the next one and it returns true. Returns false otherwise. 77 // runtime for the next one and it returns true. Returns false otherwise.
76 bool NextScheduledRunTime(base::TimeTicks* out_time) const; 78 bool NextScheduledRunTime(base::TimeTicks* out_time) const;
77 79
78 protected: 80 protected:
79 friend class internal::TaskQueueImpl; 81 friend class internal::TaskQueueImpl;
80 friend class TaskQueueManager; 82 friend class TaskQueueManager;
81 83
82 void AsValueInto(base::trace_event::TracedValue* state) const; 84 void AsValueInto(base::trace_event::TracedValue* state) const;
83 85
84 // Migrates |queue| from this time domain to |destination_time_domain|. 86 // Migrates |queue| from this time domain to |destination_time_domain|.
87 // Main-thread only.
85 void MigrateQueue(internal::TaskQueueImpl* queue, 88 void MigrateQueue(internal::TaskQueueImpl* queue,
86 TimeDomain* destination_time_domain); 89 TimeDomain* destination_time_domain);
87 90
88 // If there is a scheduled delayed task, |out_task_queue| is set to the queue 91 // If there is a scheduled delayed task, |out_task_queue| is set to the queue
89 // the next task was posted to and it returns true. Returns false otherwise. 92 // the next task was posted to and it returns true. Returns false otherwise.
90 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; 93 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const;
91 94
92 // Adds |queue| to the set of task queues that UpdateWorkQueues calls 95 // Adds |queue| to the set of task queues that UpdateWorkQueues calls
93 // UpdateWorkQueue on. 96 // UpdateWorkQueue on.
94 void RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); 97 void RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 167
165 base::ThreadChecker main_thread_checker_; 168 base::ThreadChecker main_thread_checker_;
166 169
167 DISALLOW_COPY_AND_ASSIGN(TimeDomain); 170 DISALLOW_COPY_AND_ASSIGN(TimeDomain);
168 }; 171 };
169 172
170 } // namespace scheduler 173 } // namespace scheduler
171 } // namespace blink 174 } // namespace blink
172 175
173 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ 176 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698