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

Unified Diff: content/browser/url_loader_factory_getter.h

Issue 2874163004: Add support in the network service for different contexts. (Closed)
Patch Set: update after r471804 Created 3 years, 7 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/url_loader_factory_getter.h
diff --git a/content/browser/url_loader_factory_getter.h b/content/browser/url_loader_factory_getter.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a830b398f13d303c7eb0cbf05cda1bb3bbb7239
--- /dev/null
+++ b/content/browser/url_loader_factory_getter.h
@@ -0,0 +1,54 @@
+// Copyright 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_URL_LOADER_FACTORY_GETTER_H_
+#define CONTENT_BROWSER_URL_LOADER_FACTORY_GETTER_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "content/common/content_export.h"
+#include "content/common/url_loader_factory.mojom.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+// Holds on to URLLoaderFactory for a given StoragePartition allows code running
scottmg 2017/05/16 03:53:43 "for a given StoragePartition allows code" missing
jam 2017/05/16 04:08:50 Done.
+// on the IO thread to access them. Note these are the factories used by the
+// browser process for frame requests.
+class CONTENT_EXPORT URLLoaderFactoryGetter
+ : public base::RefCountedThreadSafe<URLLoaderFactoryGetter,
+ BrowserThread::DeleteOnIOThread> {
+ public:
+ URLLoaderFactoryGetter();
+ ~URLLoaderFactoryGetter();
+
+ // Initializes this object on the UI thread.
+ void Initialize(mojom::URLLoaderFactoryPtr network_factory);
+
+ // Called on the IO thread to get the URLLoaderFactory to the network service.
+ // The pointer shouldn't be cached.
+ mojom::URLLoaderFactoryPtr* GetNetworkFactory();
+
+ // Overrides the network URLLoaderFactory for subsequent requests. Passing a
+ // null pointer will restore the default behavior.
+ // This is called on the UI thread.
+ void SetNetworkFactoryForTesting(mojom::URLLoaderFactoryPtr test_factory);
+
+ private:
+ friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
+
+ void InitializeOnIOThread(mojom::URLLoaderFactoryPtrInfo network_factory);
+ void SetTestNetworkFactoryOnIOThread(
+ mojom::URLLoaderFactoryPtrInfo test_factory);
+
+ // Only accessed on IO thread.
+ mojom::URLLoaderFactoryPtr network_factory_;
+ mojom::URLLoaderFactoryPtr test_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryGetter);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_URL_LOADER_FACTORY_GETTER_H_

Powered by Google App Engine
This is Rietveld 408576698