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

Side by Side Diff: components/scheduler/base/time_domain.h

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed various dchecks Created 5 years 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 COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ 5 #ifndef COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_
6 #define COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ 6 #define COMPONENTS_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 25 matching lines...) Expand all
36 // if possible and return true if time was advanced. 36 // if possible and return true if time was advanced.
37 virtual bool MaybeAdvanceTime() = 0; 37 virtual bool MaybeAdvanceTime() = 0;
38 38
39 // Returns the name of this time domain for tracing. 39 // Returns the name of this time domain for tracing.
40 virtual const char* GetName() const = 0; 40 virtual const char* GetName() const = 0;
41 41
42 // If there is a scheduled delayed task, |out_time| is set to the scheduled 42 // If there is a scheduled delayed task, |out_time| is set to the scheduled
43 // runtime for the next one and it returns true. Returns false otherwise. 43 // runtime for the next one and it returns true. Returns false otherwise.
44 bool NextScheduledRunTime(base::TimeTicks* out_time) const; 44 bool NextScheduledRunTime(base::TimeTicks* out_time) const;
45 45
46 class SCHEDULER_EXPORT Observer {
47 public:
48 virtual ~Observer() {}
49
50 // Called when RegisterAsUpdatableTaskQueue is called. Can fire from any
51 // thread.
52 virtual void OnRegisterAsUpdatableTaskQueue() = 0;
Sami 2015/11/24 12:48:48 How about OnHasNewWork, OnNewIncomingWork, OnNewIm
alex clarke (OOO till 29th) 2015/11/25 12:29:36 Done.
53
54 // Called when RequestWakeup is called. Called only from the main thread.
55 virtual void OnRequestWakeup() = 0;
56 };
57
58 void SetObserver(Observer* observer);
59
46 protected: 60 protected:
47 friend class internal::TaskQueueImpl; 61 friend class internal::TaskQueueImpl;
48 friend class TaskQueueManager; 62 friend class TaskQueueManager;
49 friend class base::RefCounted<TimeDomain>; 63 friend class base::RefCounted<TimeDomain>;
50 64
51 virtual ~TimeDomain(); 65 virtual ~TimeDomain();
52 66
53 void AsValueInto(base::trace_event::TracedValue* state) const; 67 void AsValueInto(base::trace_event::TracedValue* state) const;
54 68
55 // Migrates |queue| from this time domain to |destination_time_domain|. 69 // Migrates |queue| from this time domain to |destination_time_domain|.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 122
109 // This lock guards only |newly_updatable_|. It's not expected to be heavily 123 // This lock guards only |newly_updatable_|. It's not expected to be heavily
110 // contended. 124 // contended.
111 base::Lock newly_updatable_lock_; 125 base::Lock newly_updatable_lock_;
112 std::vector<internal::TaskQueueImpl*> newly_updatable_; 126 std::vector<internal::TaskQueueImpl*> newly_updatable_;
113 127
114 // Set of task queues with avaliable work on the incoming queue. This should 128 // Set of task queues with avaliable work on the incoming queue. This should
115 // only be accessed from the main thread. 129 // only be accessed from the main thread.
116 std::set<internal::TaskQueueImpl*> updatable_queue_set_; 130 std::set<internal::TaskQueueImpl*> updatable_queue_set_;
117 131
132 Observer* observer_;
133
118 base::ThreadChecker main_thread_checker_; 134 base::ThreadChecker main_thread_checker_;
119 135
120 DISALLOW_COPY_AND_ASSIGN(TimeDomain); 136 DISALLOW_COPY_AND_ASSIGN(TimeDomain);
121 }; 137 };
122 138
123 } // namespace scheduler 139 } // namespace scheduler
124 140
125 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ 141 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698