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

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

Issue 1468443002: Reduce the number of delayed tasks on chromium run loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a typo Created 5 years, 1 month 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/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 #include "components/scheduler/base/lazy_now.h" 15 #include "components/scheduler/base/lazy_now.h"
15 #include "components/scheduler/base/task_queue_impl.h" 16 #include "components/scheduler/base/task_queue_impl.h"
16 #include "components/scheduler/scheduler_export.h" 17 #include "components/scheduler/scheduler_export.h"
17 18
18 namespace scheduler { 19 namespace scheduler {
19 namespace internal { 20 namespace internal {
20 class TaskQueueImpl; 21 class TaskQueueImpl;
21 } // internal 22 } // internal
22 class TaskQueueManager; 23 class TaskQueueManager;
24 class TaskQueueManagerDelegate;
23 25
24 class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> { 26 class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> {
25 public: 27 public:
26 TimeDomain(); 28 TimeDomain();
27 29
28 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from 30 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from
29 // any thread. 31 // any thread.
30 // TODO(alexclarke): Make this main thread only. 32 // TODO(alexclarke): Make this main thread only.
31 virtual LazyNow CreateLazyNow() = 0; 33 virtual LazyNow CreateLazyNow() = 0;
32 34
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // UpdateWorkQueue on. 74 // UpdateWorkQueue on.
73 void UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); 75 void UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue);
74 76
75 // Removes |queue| from all internal data structures. 77 // Removes |queue| from all internal data structures.
76 void UnregisterQueue(internal::TaskQueueImpl* queue); 78 void UnregisterQueue(internal::TaskQueueImpl* queue);
77 79
78 // Updates active queues associated with this TimeDomain. 80 // Updates active queues associated with this TimeDomain.
79 void UpdateWorkQueues(bool should_trigger_wakeup, 81 void UpdateWorkQueues(bool should_trigger_wakeup,
80 const internal::TaskQueueImpl::Task* previous_task); 82 const internal::TaskQueueImpl::Task* previous_task);
81 83
84 // Called by the TaskQueueManager when the TimeDomain is registered.
85 virtual void OnRegisterWithTaskQueueManager(
86 TaskQueueManagerDelegate* task_queue_manager_delegate,
87 base::Closure do_work_closure) = 0;
88
82 // The implementaion will secedule task processing to run with |delay| with 89 // The implementaion will secedule task processing to run with |delay| with
83 // respect to the TimeDomain's time source. 90 // respect to the TimeDomain's time source.
84 virtual void RequestWakeup(base::TimeDelta delay) = 0; 91 virtual void RequestWakeup(LazyNow* lazy_now, base::TimeDelta delay) = 0;
85 92
86 // For implementation specific tracing. 93 // For implementation specific tracing.
87 virtual void AsValueIntoInternal( 94 virtual void AsValueIntoInternal(
88 base::trace_event::TracedValue* state) const = 0; 95 base::trace_event::TracedValue* state) const = 0;
89 96
90 // Call TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue for each 97 // Call TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue for each
91 // queue where the delay has elapsed. 98 // queue where the delay has elapsed.
92 void WakeupReadyDelayedQueues(LazyNow* lazy_now); 99 void WakeupReadyDelayedQueues(LazyNow* lazy_now);
93 100
94 private: 101 private:
(...skipping 15 matching lines...) Expand all
110 117
111 base::ThreadChecker main_thread_checker_; 118 base::ThreadChecker main_thread_checker_;
112 base::WeakPtrFactory<TimeDomain> weak_factory_; 119 base::WeakPtrFactory<TimeDomain> weak_factory_;
113 120
114 DISALLOW_COPY_AND_ASSIGN(TimeDomain); 121 DISALLOW_COPY_AND_ASSIGN(TimeDomain);
115 }; 122 };
116 123
117 } // namespace scheduler 124 } // namespace scheduler
118 125
119 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ 126 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698