Introduce update_client::NetworkFetcher as a way to abstract the network.

This is a mechanical change and work in progress.

The goal here is to decouple update client from its Chrome network
dependencies such as //net and //services/network.

This change avoids inejction of a direct dependency of the servicified
network stack in favor of injecting a NetworkFetcherFactory, which
in turns can create instances of NetworkFetcher, where they are needed.

The next change will further isolate the implementation dependencies on
the Chrome network, and allow for selecting different implementations
of the NetworkFetcher.


Bug: 929167
Change-Id: I14aff38dd7bddd5d3d6b4c1af52ccb57a06552a9
Reviewed-on: https://chromium-review.googlesource.com/c/1461337
Reviewed-by: Sylvain Defresne <[email protected]>
Reviewed-by: Martin Šrámek <[email protected]>
Reviewed-by: Minh Nguyen <[email protected]>
Reviewed-by: Joshua Pawlicki <[email protected]>
Commit-Queue: Sorin Jianu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#631250}
diff --git a/components/update_client/request_sender.h b/components/update_client/request_sender.h
index 2ffdd62..23a3fe7 100644
--- a/components/update_client/request_sender.h
+++ b/components/update_client/request_sender.h
@@ -22,13 +22,10 @@
 class Ecdsa;
 }
 
-namespace network {
-class SimpleURLLoader;
-}
-
 namespace update_client {
 
 class Configurator;
+class NetworkFetcher;
 
 // Sends a request to one of the urls provided. The class implements a chain
 // of responsibility design pattern, where the urls are tried in the order they
@@ -70,17 +67,16 @@
 
   // Returns the string value of a header of the server response or an empty
   // string if the header is not available.
-  static std::string GetStringHeaderValue(
-      const network::SimpleURLLoader* url_loader,
-      const char* header_name);
+  static std::string GetStringHeaderValue(const NetworkFetcher* url_loader,
+                                          const char* header_name);
 
   // Returns the integral value of a header of the server response or -1 if
   // if the header is not available or a conversion error has occured.
-  static int64_t GetInt64HeaderValue(const network::SimpleURLLoader* loader,
+  static int64_t GetInt64HeaderValue(const NetworkFetcher* loader,
                                      const char* header_name);
 
-  void OnSimpleURLLoaderComplete(const GURL& original_url,
-                                 std::unique_ptr<std::string> response_body);
+  void OnNetworkFetcherComplete(const GURL& original_url,
+                                std::unique_ptr<std::string> response_body);
 
   // Implements the error handling and url fallback mechanism.
   void SendInternal();
@@ -107,7 +103,7 @@
 
   std::string public_key_;
   std::vector<GURL>::const_iterator cur_url_;
-  std::unique_ptr<network::SimpleURLLoader> url_loader_;
+  std::unique_ptr<NetworkFetcher> network_fetcher_;
   std::unique_ptr<client_update_protocol::Ecdsa> signer_;
 
   DISALLOW_COPY_AND_ASSIGN(RequestSender);