Index: base/threading/thread_task_runner_handle.h |
diff --git a/base/threading/thread_task_runner_handle.h b/base/threading/thread_task_runner_handle.h |
index c8e58935f0977259349857bf91d71c63bf734567..7ae85e6dcfa8cdfe36720d8ec81653a86f2bf48a 100644 |
--- a/base/threading/thread_task_runner_handle.h |
+++ b/base/threading/thread_task_runner_handle.h |
@@ -6,6 +6,7 @@ |
#define BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ |
#include "base/base_export.h" |
+#include "base/callback_helpers.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
#include "base/single_thread_task_runner.h" |
@@ -26,6 +27,17 @@ class BASE_EXPORT ThreadTaskRunnerHandle { |
// the current thread. |
static bool IsSet(); |
+ // Overrides ThreadTaskRunnerHandle::Get()'s |task_runner_| to point at |
+ // |overriding_task_runner| until the returned ScopedClosureRunner goes out of |
+ // scope (instantiates a ThreadTaskRunnerHandle for that scope if |!IsSet()|). |
+ // Nested overrides are allowed but callers must ensure the |
+ // ScopedClosureRunners expire in LIFO (stack) order. Note: nesting |
+ // ThreadTaskRunnerHandles isn't generally desired but it's useful in unit |
+ // tests where multiple task runners can share the main thread for simplicity |
+ // and determinism. |
+ static ScopedClosureRunner OverrideForTesting( |
+ scoped_refptr<SingleThreadTaskRunner> overriding_task_runner); |
+ |
// Binds |task_runner| to the current thread. |task_runner| must belong |
// to the current thread for this to succeed. |
explicit ThreadTaskRunnerHandle( |