| 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_MESSAGE_LOOP_TASK_RUNNER_WRAPPER_H_ |
| 6 #define BASE_TEST_SCOPED_MOCK_MESSAGE_LOOP_TASK_RUNNER_WRAPPER_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 #include <memory> |
| 11 #include <queue> |
| 12 #include <vector> |
| 13 |
| 14 #include "base/macros.h" |
| 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/synchronization/lock.h" |
| 17 #include "base/test/test_pending_task.h" |
| 18 #include "base/threading/thread_checker.h" |
| 19 #include "base/time/time.h" |
| 20 |
| 21 namespace base { |
| 22 |
| 23 class TestMockTimeTaskRunner; |
| 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. |
| 30 class ScopedMockMessageLoopTaskRunnerWrapper { |
| 31 public: |
| 32 ScopedMockMessageLoopTaskRunnerWrapper(); |
| 33 ~ScopedMockMessageLoopTaskRunnerWrapper(); |
| 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(ScopedMockMessageLoopTaskRunnerWrapper); |
| 42 }; |
| 43 |
| 44 } // namespace base |
| 45 |
| 46 #endif // BASE_TEST_SCOPED_MOCK_MESSAGE_LOOP_TASK_RUNNER_WRAPPER_H_ |
| OLD | NEW |