OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_TEST_SCOPED_MOCK_TIME_MESSAGE_LOOP_TASK_RUNNER_H_ | |
6 #define BASE_TEST_SCOPED_MOCK_TIME_MESSAGE_LOOP_TASK_RUNNER_H_ | |
7 | |
8 #include <stddef.h> | |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
| |
9 | |
10 #include <memory> | |
gab
2016/11/18 15:13:54
For scoped_refptr you don't need this one, you nee
bruthig
2016/11/18 16:44:52
Done.
| |
11 #include <queue> | |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
| |
12 #include <vector> | |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
| |
13 | |
14 #include "base/macros.h" | |
15 #include "base/single_thread_task_runner.h" | |
gab
2016/11/18 15:13:54
nit: include only required in .cc (fwd-decl below
bruthig
2016/11/18 16:44:53
Done.
| |
16 #include "base/synchronization/lock.h" | |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:53
Done.
| |
17 #include "base/test/test_pending_task.h" | |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
| |
18 #include "base/threading/thread_checker.h" | |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
| |
19 #include "base/time/time.h" | |
gab
2016/11/18 15:13:54
to .cc
bruthig
2016/11/18 16:44:53
Done.
| |
20 | |
21 namespace base { | |
22 | |
23 class TestMockTimeTaskRunner; | |
gab
2016/11/18 15:13:54
Since I can't imagine anyone using this class with
gab
2016/11/18 15:13:54
Along similar lines of thoughts as the above how a
bruthig
2016/11/18 16:44:52
Done.
bruthig
2016/11/18 16:44:52
Done.
| |
24 class SingleThreadTaskRunner; | |
25 | |
26 // A scoped wrapper around TestMockTimeTaskRunner that replaces | |
27 // MessageLoop::current()'s task runner (and consequently | |
28 // ThreadTaskRunnerHandle) with a TestMockTimeTaskRunner and resets it back at | |
29 // the end of the scope. | |
gab
2016/11/18 15:13:54
Another thing I noticed when using this for my own
bruthig
2016/11/18 16:44:52
Done.
| |
30 class ScopedMockTimeMessageLoopTaskRunner { | |
31 public: | |
32 ScopedMockTimeMessageLoopTaskRunner(); | |
33 ~ScopedMockTimeMessageLoopTaskRunner(); | |
34 | |
35 TestMockTimeTaskRunner* task_runner() { return task_runner_.get(); } | |
36 | |
37 private: | |
38 const scoped_refptr<TestMockTimeTaskRunner> task_runner_; | |
39 scoped_refptr<SingleThreadTaskRunner> previous_task_runner_; | |
40 | |
41 DISALLOW_COPY_AND_ASSIGN(ScopedMockTimeMessageLoopTaskRunner); | |
42 }; | |
43 | |
44 } // namespace base | |
45 | |
46 #endif // BASE_TEST_SCOPED_MOCK_TIME_MESSAGE_LOOP_TASK_RUNNER_H_ | |
OLD | NEW |