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

Unified Diff: content/browser/loader/loader_globals.h

Issue 2785523002: Reduce/remove usage of BrowserThread in content/browser/loader. (Closed)
Patch Set: Fix unittests redness Created 3 years, 9 months 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/loader/loader_globals.h
diff --git a/content/browser/loader/loader_globals.h b/content/browser/loader/loader_globals.h
new file mode 100644
index 0000000000000000000000000000000000000000..4ec520b2fbb19bd2bebf1a57a73486787dc279bd
--- /dev/null
+++ b/content/browser/loader/loader_globals.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2017 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 CONTENT_BROWSER_LOADER_LOADER_GLOBALS_H_
+#define CONTENT_BROWSER_LOADER_LOADER_GLOBALS_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+// Contains global state for the network loader sources. Only one instance of
+// this class is active at any given point.
+class CONTENT_EXPORT LoaderGlobals {
+ public:
+ // Returns a pointer to the global instance.
+ static LoaderGlobals* Get();
+
+ LoaderGlobals(
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner);
+
+ ~LoaderGlobals();
+
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner() const {
+ return io_thread_task_runner_;
+ }
+
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner() const {
+ return main_thread_task_runner_;
+ }
+
+ private:
+ // Task runner to be used for posting tasks to the main thread.
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
+
+ // Task runner to be used for posting tasks to the IO thread.
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_LOADER_GLOBALS_H_

Powered by Google App Engine
This is Rietveld 408576698