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

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: Rebased 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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/scheduler/base/lazy_now.h" 15 #include "components/scheduler/base/lazy_now.h"
16 #include "components/scheduler/base/task_queue_impl.h" 16 #include "components/scheduler/base/task_queue_impl.h"
17 #include "components/scheduler/scheduler_export.h" 17 #include "components/scheduler/scheduler_export.h"
18 18
19 namespace scheduler { 19 namespace scheduler {
20 namespace internal { 20 namespace internal {
21 class TaskQueueImpl; 21 class TaskQueueImpl;
22 } // internal 22 } // internal
23 class TaskQueueManager; 23 class TaskQueueManager;
24 class TaskQueueManagerDelegate; 24 class TaskQueueManagerDelegate;
25 25
26 class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> { 26 class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> {
27 public: 27 public:
28 TimeDomain(); 28 class SCHEDULER_EXPORT Observer {
29 public:
30 virtual ~Observer() {}
31
32 // Called when RegisterAsUpdatableTaskQueue is called. Can fire from any
Sami 2015/11/25 17:12:25 nit: these two comments don't really make sense un
alex clarke (OOO till 29th) 2015/11/26 18:43:27 Done.
33 // thread.
34 virtual void OnTimeDomainHasImmediateWork() = 0;
35
36 // Called when RequestWakeup is called. Called only from the main thread.
37 virtual void OnTimeDomainHasDelayedWork() = 0;
38 };
39
40 explicit TimeDomain(Observer* observer);
29 41
30 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from 42 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from
31 // any thread. 43 // any thread.
32 // TODO(alexclarke): Make this main thread only. 44 // TODO(alexclarke): Make this main thread only.
33 virtual LazyNow CreateLazyNow() = 0; 45 virtual LazyNow CreateLazyNow() = 0;
34 46
35 // Some TimeDomains support virtual time, this method tells us to advance time 47 // Some TimeDomains support virtual time, this method tells us to advance time
36 // if possible and return true if time was advanced. 48 // if possible and return true if time was advanced.
37 virtual bool MaybeAdvanceTime() = 0; 49 virtual bool MaybeAdvanceTime() = 0;
38 50
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 120
109 // This lock guards only |newly_updatable_|. It's not expected to be heavily 121 // This lock guards only |newly_updatable_|. It's not expected to be heavily
110 // contended. 122 // contended.
111 base::Lock newly_updatable_lock_; 123 base::Lock newly_updatable_lock_;
112 std::vector<internal::TaskQueueImpl*> newly_updatable_; 124 std::vector<internal::TaskQueueImpl*> newly_updatable_;
113 125
114 // Set of task queues with avaliable work on the incoming queue. This should 126 // Set of task queues with avaliable work on the incoming queue. This should
115 // only be accessed from the main thread. 127 // only be accessed from the main thread.
116 std::set<internal::TaskQueueImpl*> updatable_queue_set_; 128 std::set<internal::TaskQueueImpl*> updatable_queue_set_;
117 129
130 Observer* observer_;
131
118 base::ThreadChecker main_thread_checker_; 132 base::ThreadChecker main_thread_checker_;
119 133
120 DISALLOW_COPY_AND_ASSIGN(TimeDomain); 134 DISALLOW_COPY_AND_ASSIGN(TimeDomain);
121 }; 135 };
122 136
123 } // namespace scheduler 137 } // namespace scheduler
124 138
125 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ 139 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698