OLD | NEW |
---|---|
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_TASK_RUNNER_DELEGATE_IMPL_H_ | 5 #ifndef COMPONENTS_SCHEDULER_CHILD_VIRTUAL_TIME_TASK_RUNNER_DELEGATE_IMPL_H_ |
6 #define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_TASK_RUNNER_DELEGATE_IMPL_H_ | 6 #define COMPONENTS_SCHEDULER_CHILD_VIRTUAL_TIME_TASK_RUNNER_DELEGATE_IMPL_H_ |
7 | 7 |
8 #include <map> | |
9 | |
10 #include "base/macros.h" | |
8 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/time/tick_clock.h" | |
9 #include "components/scheduler/child/scheduler_task_runner_delegate.h" | 13 #include "components/scheduler/child/scheduler_task_runner_delegate.h" |
10 #include "components/scheduler/scheduler_export.h" | 14 #include "components/scheduler/scheduler_export.h" |
11 | 15 |
12 namespace scheduler { | 16 namespace scheduler { |
13 | 17 |
14 class SCHEDULER_EXPORT SchedulerTaskRunnerDelegateImpl | 18 class SCHEDULER_EXPORT VirtualTimeTaskRunnerDelegateImpl |
15 : public SchedulerTaskRunnerDelegate { | 19 : public SchedulerTaskRunnerDelegate { |
16 public: | 20 public: |
17 // |message_loop| is not owned and must outlive the lifetime of this object. | 21 // |message_loop| is not owned and must outlive the lifetime of this object. |
18 static scoped_refptr<SchedulerTaskRunnerDelegateImpl> Create( | 22 static scoped_refptr<VirtualTimeTaskRunnerDelegateImpl> Create( |
19 base::MessageLoop* message_loop); | 23 base::MessageLoop* message_loop, |
24 base::TimeTicks initial_now); | |
20 | 25 |
21 // SchedulerTaskRunnerDelegate implementation | 26 // SchedulerTaskRunnerDelegate implementation |
22 void SetDefaultTaskRunner( | 27 void SetDefaultTaskRunner( |
23 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; | 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; |
24 void RestoreDefaultTaskRunner() override; | 29 void RestoreDefaultTaskRunner() override; |
25 bool PostDelayedTask(const tracked_objects::Location& from_here, | 30 bool PostDelayedTask(const tracked_objects::Location& from_here, |
26 const base::Closure& task, | 31 const base::Closure& task, |
27 base::TimeDelta delay) override; | 32 base::TimeDelta delay) override; |
28 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 33 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
29 const base::Closure& task, | 34 const base::Closure& task, |
30 base::TimeDelta delay) override; | 35 base::TimeDelta delay) override; |
31 bool RunsTasksOnCurrentThread() const override; | 36 bool RunsTasksOnCurrentThread() const override; |
32 bool IsNested() const override; | 37 bool IsNested() const override; |
38 base::TimeTicks NowTicks() override; | |
39 void OnNoMoreWork() override; | |
40 | |
41 void SetFastForwardTimers(bool fast_forward_timers); | |
Sami
2015/10/28 20:00:35
nit: "Timers" aren't really a thing at this level.
alex clarke (OOO till 29th)
2015/10/29 18:07:30
Yeah looks like this isn't needed anymore.
| |
33 | 42 |
34 protected: | 43 protected: |
35 ~SchedulerTaskRunnerDelegateImpl() override; | 44 ~VirtualTimeTaskRunnerDelegateImpl() override; |
36 | 45 |
37 private: | 46 private: |
38 explicit SchedulerTaskRunnerDelegateImpl(base::MessageLoop* message_loop); | 47 VirtualTimeTaskRunnerDelegateImpl(base::MessageLoop* message_loop, |
48 base::TimeTicks initial_no); | |
49 | |
50 void AdvancedTimeTo(base::TimeTicks now); | |
51 | |
52 typedef std::multimap<base::TimeTicks, base::Closure> DelayedWakeupMultimap; | |
53 | |
54 DelayedWakeupMultimap delayed_wakeup_multimap_; | |
39 | 55 |
40 // Not owned. | 56 // Not owned. |
41 base::MessageLoop* message_loop_; | 57 base::MessageLoop* message_loop_; |
42 scoped_refptr<SingleThreadTaskRunner> message_loop_task_runner_; | 58 scoped_refptr<SingleThreadTaskRunner> message_loop_task_runner_; |
59 base::TimeTicks now_; | |
60 bool bool fast_forward_timers_; | |
Sami
2015/10/28 20:00:35
typo: double bool (didn't realize this even compil
alex clarke (OOO till 29th)
2015/10/29 18:07:30
Done.
| |
43 | 61 |
44 DISALLOW_COPY_AND_ASSIGN(SchedulerTaskRunnerDelegateImpl); | 62 DISALLOW_COPY_AND_ASSIGN(VirtualTimeTaskRunnerDelegateImpl); |
45 }; | 63 }; |
46 | 64 |
47 } // namespace scheduler | 65 } // namespace scheduler |
48 | 66 |
49 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_TASK_RUNNER_DELEGATE_IMPL_H_ | 67 #endif // COMPONENTS_SCHEDULER_CHILD_VIRTUAL_TIME_TASK_RUNNER_DELEGATE_IMPL_H_ |
OLD | NEW |