[XHR] Replace usage of download_to_file with new download_to_blob feature.

download_to_file isn't really implementable with the network service (since
there is no central browser-side place where all fetches pass through), and
because we'd like blobs downloaded by XHR to be managed by the blob system
anyway, this replaces download_to_file with a new download_to_blob feature.

With this, blink::ResourceLoader redirects the datapipe it receives from a
URLLoader to the blob system, and passes the resulting blob back to XHR.

Design doc: https://docs.google.com/document/d/1V_rFqFeYc_XpzEc_hGF9Wlat5mH62lREJ1I1dCJ4lX0/edit#heading=h.2ndyupa99wqr

Bug: 754493, 712693, 791702

Change-Id: I258150937c424b72824dadbc2832764ed54c1ca5
Reviewed-on: https://chromium-review.googlesource.com/955957
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Yutaka Hirano <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Commit-Queue: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/master@{#547248}
diff --git a/content/renderer/loader/url_loader_client_impl.h b/content/renderer/loader/url_loader_client_impl.h
index 26b9241..96712b0 100644
--- a/content/renderer/loader/url_loader_client_impl.h
+++ b/content/renderer/loader/url_loader_client_impl.h
@@ -47,9 +47,17 @@
   // Unsets |is_deferred_|.
   void UnsetDefersLoading();
 
-  // Disaptches the messages received after SetDefersLoading is called.
+  // Dispatches the messages received after SetDefersLoading is called.
   void FlushDeferredMessages();
 
+  // If set to true, this causes the raw datapipe containing the response body
+  // to be passed on to the ResourceDispatcher. Otherwise a
+  // URLResponseBodyConsumer is created that passes individual chunks of data
+  // from teh body to the dispatcher.
+  void SetPassResponsePipeToDispatcher(bool pass_pipe) {
+    pass_response_pipe_to_dispatcher_ = true;
+  }
+
   // Binds this instance to the given URLLoaderClient endpoints so that it can
   // start getting the mojo calls from the given loader. This is used only for
   // the main resource loading when NavigationMojoResponse and/or NetworkService
@@ -99,6 +107,7 @@
   bool has_received_response_ = false;
   bool has_received_complete_ = false;
   bool is_deferred_ = false;
+  bool pass_response_pipe_to_dispatcher_ = false;
   int32_t accumulated_transfer_size_diff_during_deferred_ = 0;
   ResourceDispatcher* const resource_dispatcher_;
   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;