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

Side by Side Diff: cc/test/ordered_simple_task_runner.h

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Using SizeTToString rather then c++11 to_string. Created 6 years, 4 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 5 #ifndef CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
7 7
8 #include <deque>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/debug/trace_event.h"
13 #include "base/logging.h"
10 #include "base/test/test_simple_task_runner.h" 14 #include "base/test/test_simple_task_runner.h"
11 15
12 namespace cc { 16 namespace cc {
13 17
14 // This runs pending tasks based on task's post_time + delay. 18 // This runs pending tasks based on task's post_time + delay.
15 // We should not execute a delayed task sooner than some of the queued tasks 19 // We should not execute a delayed task sooner than some of the queued tasks
16 // which don't have a delay even though it is queued early. 20 // which don't have a delay even though it is queued early.
17 class OrderedSimpleTaskRunner : public base::TestSimpleTaskRunner { 21 class OrderedSimpleTaskRunner : public base::TestSimpleTaskRunner {
18 public: 22 public:
19 OrderedSimpleTaskRunner(); 23 explicit OrderedSimpleTaskRunner(bool advance_now = true);
Sami 2014/08/19 18:45:04 No default arguments in chromium please :P
mithro-old 2014/08/21 17:39:18 How does one do this otherwise?
20 24
Sami 2014/08/19 18:45:04 // base::TestSimpleTaskRunner implementation:
mithro-old 2014/08/21 17:39:18 Done.
25 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
26 const base::Closure& task,
27 base::TimeDelta delay) OVERRIDE;
28 virtual bool PostNonNestableDelayedTask(
Sami 2014/08/19 18:45:04 Just curious: do we ever post non-nestable tasks f
mithro-old 2014/08/21 17:39:19 No idea. I do think this task runner could possibl
29 const tracked_objects::Location& from_here,
30 const base::Closure& task,
31 base::TimeDelta delay) OVERRIDE;
21 virtual void RunPendingTasks() OVERRIDE; 32 virtual void RunPendingTasks() OVERRIDE;
22 33
34 base::TimeTicks Now() const;
brianderson 2014/08/20 20:04:31 protected not public.
mithro-old 2014/08/21 17:39:19 Done.
35 base::TimeDelta DelayToNextPendingTask();
36 void SetAutoAdvanceNowToPendingTasks(bool advance_now);
37 void SetNow(base::TimeTicks time);
brianderson 2014/08/20 20:04:31 Remove this.
mithro-old 2014/08/21 17:39:19 Done.
38
39 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
40
23 protected: 41 protected:
24 virtual ~OrderedSimpleTaskRunner(); 42 virtual ~OrderedSimpleTaskRunner();
25 43
44 static void SortTasks(std::deque<base::TestPendingTask>* tasks);
45
26 private: 46 private:
47 bool advance_now_;
48 base::TimeTicks now_;
49 bool inside_run_pending_tasks_;
50
51 friend void PrintTo(const OrderedSimpleTaskRunner& t, ::std::ostream* os);
52
27 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); 53 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner);
28 }; 54 };
29 55
30 } // namespace cc 56 } // namespace cc
31 57
32 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 58 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698