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 BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 5 #ifndef BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 | 158 |
159 // The ordinal to use for the next task. Must only be accessed while the | 159 // The ordinal to use for the next task. Must only be accessed while the |
160 // |tasks_lock_| is held. | 160 // |tasks_lock_| is held. |
161 size_t next_task_ordinal_; | 161 size_t next_task_ordinal_; |
162 | 162 |
163 Lock tasks_lock_; | 163 Lock tasks_lock_; |
164 | 164 |
165 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); | 165 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); |
166 }; | 166 }; |
167 | 167 |
168 // A scoped wrapper around TestMockTimeTaskRunner that replaces message loop's | |
gab
2016/11/15 19:52:01
s/message loop's task runner/MessageLoop::current(
bruthig
2016/11/15 21:52:45
Done.
| |
169 // task runner with a TestMockTimeTaskRunner and resets it back at the end of | |
170 // the scope. | |
171 class ScopedMockTaskRunnerWrapper { | |
gab
2016/11/15 19:52:01
Make name ML specific, i.e. ScopedMockMessageLoopT
danakj
2016/11/15 19:58:13
I think this class could go in its own .h and .cc
bruthig
2016/11/15 21:52:45
Done.
bruthig
2016/11/15 21:52:45
Done.
| |
172 public: | |
173 ScopedMockTaskRunnerWrapper(); | |
174 virtual ~ScopedMockTaskRunnerWrapper(); | |
gab
2016/11/15 19:52:01
non-virtual destructor for class with no virtual m
bruthig
2016/11/15 21:52:45
Done.
| |
175 | |
176 base::TestMockTimeTaskRunner* task_runner() { return task_runner_.get(); } | |
gab
2016/11/15 19:52:01
const
bruthig
2016/11/15 21:52:45
If we return a "const TestMockTimeTaskRunner*" the
gab
2016/11/15 22:02:05
Sorry, I meant to make the method const, i.e.
ba
bruthig
2016/11/15 22:17:57
Are you sure? The style guide advises not to make
gab
2016/11/15 23:16:59
Ah interesting, had missed that part of it, please
| |
177 | |
178 private: | |
179 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; | |
gab
2016/11/15 19:52:01
const (will also require to move initialization to
bruthig
2016/11/15 21:52:45
Done, but not sure if you meant
const scoped_refpt
gab
2016/11/15 22:02:05
const scoped_refptr<TestMockTimeTaskRunner>
(i.e.
bruthig
2016/11/15 22:17:57
Thx
| |
180 scoped_refptr<base::SingleThreadTaskRunner> previous_task_runner_; | |
gab
2016/11/15 19:52:01
nit: no base:: prefix above nor in .cc file (this
bruthig
2016/11/15 21:52:44
Done.
| |
181 | |
182 DISALLOW_COPY_AND_ASSIGN(ScopedMockTaskRunnerWrapper); | |
183 }; | |
184 | |
168 } // namespace base | 185 } // namespace base |
169 | 186 |
170 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 187 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
OLD | NEW |