Index: base/test/scoped_mock_time_message_loop_task_runner.h |
diff --git a/base/test/scoped_mock_time_message_loop_task_runner.h b/base/test/scoped_mock_time_message_loop_task_runner.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a6ec64fd584fb1f7ff5e5309b31002be800eca9b |
--- /dev/null |
+++ b/base/test/scoped_mock_time_message_loop_task_runner.h |
@@ -0,0 +1,46 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_TEST_SCOPED_MOCK_TIME_MESSAGE_LOOP_TASK_RUNNER_H_ |
+#define BASE_TEST_SCOPED_MOCK_TIME_MESSAGE_LOOP_TASK_RUNNER_H_ |
+ |
+#include <stddef.h> |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
|
+ |
+#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.
|
+#include <queue> |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
|
+#include <vector> |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
|
+ |
+#include "base/macros.h" |
+#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.
|
+#include "base/synchronization/lock.h" |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:53
Done.
|
+#include "base/test/test_pending_task.h" |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
|
+#include "base/threading/thread_checker.h" |
gab
2016/11/18 15:13:54
rm
bruthig
2016/11/18 16:44:52
Done.
|
+#include "base/time/time.h" |
gab
2016/11/18 15:13:54
to .cc
bruthig
2016/11/18 16:44:53
Done.
|
+ |
+namespace base { |
+ |
+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.
|
+class SingleThreadTaskRunner; |
+ |
+// A scoped wrapper around TestMockTimeTaskRunner that replaces |
+// MessageLoop::current()'s task runner (and consequently |
+// ThreadTaskRunnerHandle) with a TestMockTimeTaskRunner and resets it back at |
+// 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.
|
+class ScopedMockTimeMessageLoopTaskRunner { |
+ public: |
+ ScopedMockTimeMessageLoopTaskRunner(); |
+ ~ScopedMockTimeMessageLoopTaskRunner(); |
+ |
+ TestMockTimeTaskRunner* task_runner() { return task_runner_.get(); } |
+ |
+ private: |
+ const scoped_refptr<TestMockTimeTaskRunner> task_runner_; |
+ scoped_refptr<SingleThreadTaskRunner> previous_task_runner_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedMockTimeMessageLoopTaskRunner); |
+}; |
+ |
+} // namespace base |
+ |
+#endif // BASE_TEST_SCOPED_MOCK_TIME_MESSAGE_LOOP_TASK_RUNNER_H_ |