akalin@chromium.org | 4fb2deb | 2012-12-28 04:58:00 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | |
danakj | 0393da3 | 2015-03-10 09:31:16 +0900 | [diff] [blame] | 5 | #ifndef BASE_TEST_NULL_TASK_RUNNER_H_ |
| 6 | #define BASE_TEST_NULL_TASK_RUNNER_H_ |
| 7 | |
tzik | 622d59e | 2017-03-29 14:28:12 +0900 | [diff] [blame] | 8 | #include "base/callback.h" |
akalin@chromium.org | 4fb2deb | 2012-12-28 04:58:00 +0900 | [diff] [blame] | 9 | #include "base/compiler_specific.h" |
avi | f09d539 | 2015-12-24 12:28:02 +0900 | [diff] [blame] | 10 | #include "base/macros.h" |
akalin@chromium.org | 4fb2deb | 2012-12-28 04:58:00 +0900 | [diff] [blame] | 11 | #include "base/single_thread_task_runner.h" |
| 12 | |
| 13 | namespace base { |
| 14 | |
| 15 | // Helper class for tests that need to provide an implementation of a |
| 16 | // *TaskRunner class but don't actually care about tasks being run. |
| 17 | |
| 18 | class NullTaskRunner : public base::SingleThreadTaskRunner { |
| 19 | public: |
| 20 | NullTaskRunner(); |
| 21 | |
Brett Wilson | 89388db | 2017-09-12 14:22:16 +0900 | [diff] [blame] | 22 | bool PostDelayedTask(const Location& from_here, |
tzik | 8f0ce10 | 2017-04-05 19:13:21 +0900 | [diff] [blame] | 23 | base::OnceClosure task, |
dcheng | 7dc8df5 | 2014-10-21 19:54:51 +0900 | [diff] [blame] | 24 | base::TimeDelta delay) override; |
Brett Wilson | 89388db | 2017-09-12 14:22:16 +0900 | [diff] [blame] | 25 | bool PostNonNestableDelayedTask(const Location& from_here, |
tzik | 8f0ce10 | 2017-04-05 19:13:21 +0900 | [diff] [blame] | 26 | base::OnceClosure task, |
dcheng | 7dc8df5 | 2014-10-21 19:54:51 +0900 | [diff] [blame] | 27 | base::TimeDelta delay) override; |
akalin@chromium.org | 4fb2deb | 2012-12-28 04:58:00 +0900 | [diff] [blame] | 28 | // Always returns true to avoid triggering DCHECKs. |
peary2 | a22cfdb | 2017-05-09 12:55:48 +0900 | [diff] [blame] | 29 | bool RunsTasksInCurrentSequence() const override; |
akalin@chromium.org | 4fb2deb | 2012-12-28 04:58:00 +0900 | [diff] [blame] | 30 | |
| 31 | protected: |
dcheng | 7dc8df5 | 2014-10-21 19:54:51 +0900 | [diff] [blame] | 32 | ~NullTaskRunner() override; |
akalin@chromium.org | 4fb2deb | 2012-12-28 04:58:00 +0900 | [diff] [blame] | 33 | |
| 34 | DISALLOW_COPY_AND_ASSIGN(NullTaskRunner); |
| 35 | }; |
| 36 | |
danakj | 651c3e2 | 2015-03-07 10:51:42 +0900 | [diff] [blame] | 37 | } // namespace base |
danakj | 0393da3 | 2015-03-10 09:31:16 +0900 | [diff] [blame] | 38 | |
| 39 | #endif // BASE_TEST_NULL_TASK_RUNNER_H_ |