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

Side by Side Diff: components/scheduler/child/scheduler_helper.h

Issue 1424053002: Adds a flag to support "Virtual Time" to the blink scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another try 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_CHILD_SCHEDULER_HELPER_H_ 5 #ifndef COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_
6 #define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ 6 #define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_
7 7
8 #include "base/time/tick_clock.h"
8 #include "components/scheduler/base/task_queue_manager.h" 9 #include "components/scheduler/base/task_queue_manager.h"
9 #include "components/scheduler/base/task_queue_selector.h" 10 #include "components/scheduler/base/task_queue_selector.h"
10 #include "components/scheduler/scheduler_export.h" 11 #include "components/scheduler/scheduler_export.h"
11 12
12 namespace base { 13 namespace base {
13 class TickClock; 14 class TickClock;
14 } 15 }
15 16
16 namespace scheduler { 17 namespace scheduler {
17 18
18 class SchedulerTaskRunnerDelegate; 19 class SchedulerTqmDelegate;
19 20
20 // Common scheduler functionality for default tasks. 21 // Common scheduler functionality for default tasks.
21 class SCHEDULER_EXPORT SchedulerHelper : public TaskQueueManager::Observer { 22 class SCHEDULER_EXPORT SchedulerHelper : public TaskQueueManager::Observer {
22 public: 23 public:
23 // Category strings must have application lifetime (statics or 24 // Category strings must have application lifetime (statics or
24 // literals). They may not include " chars. 25 // literals). They may not include " chars.
25 SchedulerHelper(scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner, 26 SchedulerHelper(scoped_refptr<SchedulerTqmDelegate> main_task_runner,
Sami 2015/10/30 14:09:50 Should we do a global rename of |main_task_runner|
alex clarke (OOO till 29th) 2015/10/30 16:02:00 Done.
26 const char* tracing_category, 27 const char* tracing_category,
27 const char* disabled_by_default_tracing_category, 28 const char* disabled_by_default_tracing_category,
28 const char* disabled_by_default_verbose_tracing_category); 29 const char* disabled_by_default_verbose_tracing_category);
29 ~SchedulerHelper() override; 30 ~SchedulerHelper() override;
30 31
31 // TaskQueueManager::Observer implementation: 32 // TaskQueueManager::Observer implementation:
32 void OnUnregisterTaskQueue( 33 void OnUnregisterTaskQueue(
33 const scoped_refptr<internal::TaskQueueImpl>& queue) override; 34 const scoped_refptr<internal::TaskQueueImpl>& queue) override;
34 35
35 // Returns the default task runner. 36 // Returns the default task runner.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 virtual void OnUnregisterTaskQueue( 75 virtual void OnUnregisterTaskQueue(
75 const scoped_refptr<TaskQueue>& queue) = 0; 76 const scoped_refptr<TaskQueue>& queue) = 0;
76 }; 77 };
77 78
78 // Called once to set the Observer. This function is called on the main 79 // Called once to set the Observer. This function is called on the main
79 // thread. If |observer| is null, then no callbacks will occur. 80 // thread. If |observer| is null, then no callbacks will occur.
80 // Note |observer| is expected to outlive the SchedulerHelper. 81 // Note |observer| is expected to outlive the SchedulerHelper.
81 void SetObserver(Observer* observer); 82 void SetObserver(Observer* observer);
82 83
83 // Accessor methods. 84 // Accessor methods.
84 base::TimeTicks Now() const; 85 base::TickClock* tick_clock() const;
85 base::TimeTicks NextPendingDelayedTaskRunTime() const; 86 base::TimeTicks NextPendingDelayedTaskRunTime() const;
86 bool GetAndClearSystemIsQuiescentBit(); 87 bool GetAndClearSystemIsQuiescentBit();
87 88
88 // Test helpers. 89 // Test helpers.
89 void SetTimeSourceForTesting(scoped_ptr<base::TickClock> time_source);
90 void SetWorkBatchSizeForTesting(size_t work_batch_size); 90 void SetWorkBatchSizeForTesting(size_t work_batch_size);
91 TaskQueueManager* GetTaskQueueManagerForTesting(); 91 TaskQueueManager* GetTaskQueueManagerForTesting();
92 92
93 private: 93 private:
94 friend class SchedulerHelperTest; 94 friend class SchedulerHelperTest;
95 95
96 base::ThreadChecker thread_checker_; 96 base::ThreadChecker thread_checker_;
97 scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner_; 97 scoped_refptr<SchedulerTqmDelegate> main_task_runner_;
98 scoped_ptr<TaskQueueManager> task_queue_manager_; 98 scoped_ptr<TaskQueueManager> task_queue_manager_;
99 scoped_refptr<TaskQueue> control_task_runner_; 99 scoped_refptr<TaskQueue> control_task_runner_;
100 scoped_refptr<TaskQueue> control_after_wakeup_task_runner_; 100 scoped_refptr<TaskQueue> control_after_wakeup_task_runner_;
101 scoped_refptr<TaskQueue> default_task_runner_; 101 scoped_refptr<TaskQueue> default_task_runner_;
102 102
103 scoped_ptr<base::TickClock> time_source_;
104
105 Observer* observer_; // NOT OWNED 103 Observer* observer_; // NOT OWNED
106 const char* tracing_category_; 104 const char* tracing_category_;
107 const char* disabled_by_default_tracing_category_; 105 const char* disabled_by_default_tracing_category_;
108 106
109 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper); 107 DISALLOW_COPY_AND_ASSIGN(SchedulerHelper);
110 }; 108 };
111 109
112 } // namespace scheduler 110 } // namespace scheduler
113 111
114 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_ 112 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698