Add a URLLoaderFactory implementation in src/ios for use by components.

This is backed by services/network/url_loader implementation. This allows components that are
shared with src/chrome to use URLLoader instead of URLFetcher.

Old:
Layered components take BrowserState::GetRequestContext() and pass it to to net::URLFetcher.

New:
Layered components take BrowserState::GetURLLoaderFactory() and pass it to network::SimpleURLLoader.

Bug: 803149
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ie4723ca17467f0372eed4d999544351152702e3e
Reviewed-on: https://chromium-review.googlesource.com/907543
Commit-Queue: John Abd-El-Malek <[email protected]>
Reviewed-by: Eugene But <[email protected]>
Cr-Commit-Position: refs/heads/master@{#535472}
diff --git a/ios/web/public/browser_state.h b/ios/web/public/browser_state.h
index f900a3b..705c183 100644
--- a/ios/web/public/browser_state.h
+++ b/ios/web/public/browser_state.h
@@ -5,6 +5,8 @@
 #ifndef IOS_WEB_PUBLIC_BROWSER_STATE_H_
 #define IOS_WEB_PUBLIC_BROWSER_STATE_H_
 
+#include <memory>
+
 #include "base/supports_user_data.h"
 #include "services/service_manager/embedder/embedded_service_info.h"
 
@@ -16,6 +18,12 @@
 class URLRequestContextGetter;
 }
 
+namespace network {
+namespace mojom {
+class URLLoaderFactory;
+}
+}  // namespace network
+
 namespace service_manager {
 class Connector;
 }
@@ -50,6 +58,9 @@
   // BrowserState.
   virtual net::URLRequestContextGetter* GetRequestContext() = 0;
 
+  // Returns a URLLoaderFactory that is backed by GetRequestContext.
+  network::mojom::URLLoaderFactory* GetURLLoaderFactory();
+
   // Safely cast a base::SupportsUserData to a BrowserState. Returns nullptr
   // if |supports_user_data| is not a BrowserState.
   static BrowserState* FromSupportsUserData(
@@ -87,6 +98,7 @@
                          const base::FilePath& path);
 
  private:
+  class URLLoaderFactory;
   friend class URLDataManagerIOS;
   friend class URLRequestChromeJob;
 
@@ -96,6 +108,8 @@
   // Not intended for usage outside of //web.
   URLDataManagerIOSBackend* GetURLDataManagerIOSBackendOnIOThread();
 
+  std::unique_ptr<URLLoaderFactory> url_loader_factory_;
+
   // The URLDataManagerIOSBackend instance associated with this BrowserState.
   // Created and destroyed on the IO thread, and should be accessed only from
   // the IO thread.