summaryrefslogtreecommitdiff
path: root/base/threading/thread_task_runner_handle.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/threading/thread_task_runner_handle.h')
-rw-r--r--base/threading/thread_task_runner_handle.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/base/threading/thread_task_runner_handle.h b/base/threading/thread_task_runner_handle.h
index c8e58935f0..7ae85e6dcf 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(