Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: content/browser/browser_thread_impl.h

Issue 2464233002: Experiment with redirecting all BrowserThreads (but UI/IO) to TaskScheduler (Closed)
Patch Set: Add ResetGlobalsForTesting() and fix shutdown state in unittests Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_thread_impl.h
diff --git a/content/browser/browser_thread_impl.h b/content/browser/browser_thread_impl.h
index e86f4ec907a76f9fe3aab439db527f4d94f94935..7329dcb8986619f1f2664db5308fc2eb5f976ade 100644
--- a/content/browser/browser_thread_impl.h
+++ b/content/browser/browser_thread_impl.h
@@ -5,7 +5,8 @@
#ifndef CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
#define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
-#include "base/threading/platform_thread.h"
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
@@ -26,12 +27,23 @@ class CONTENT_EXPORT BrowserThreadImpl : public BrowserThread,
base::MessageLoop* message_loop);
~BrowserThreadImpl() override;
- bool Start();
- bool StartWithOptions(const Options& options);
- bool StartAndWaitForTesting();
+ // Redirects tasks posted to |identifier| to |task_runner|. |task_runner| may
+ // be null to cancel the redirection and have |identifier| enter its
+ // "shutdown" phase.
+ static void RedirectThreadIDToTaskRunner(
+ BrowserThread::ID identifier,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner);
static void ShutdownThreadPool();
+ // Resets globals for |identifier|. Used in tests to clear global state that
+ // would otherwise leak to the next test. Globals are not otherwise fully
+ // cleaned up in ~BrowserThreadImpl() as there are subtle differences between
+ // UNINITIALIZED and SHUTDOWN state (e.g. globals.task_runners are kept around
+ // on shutdown). Must be called after ~BrowserThreadImpl() for the given
+ // |identifier|.
+ static void ResetGlobalsForTesting(BrowserThread::ID identifier);
+
protected:
void Init() override;
void Run(base::RunLoop* run_loop) override;

Powered by Google App Engine
This is Rietveld 408576698