Revert "Transmit the response's body datapipe in CommitNavigation()."

This reverts commit 7521deccbb7d3d4a7700e6e007e679a8706d8be0.

Reason for revert: Caused failures on fast/history/history-back-initial-vs-final-url.html (and possibly other tests, see https://crbug.com/861808)

Original change's description:
> Transmit the response's body datapipe in CommitNavigation().
> 
> # Summary of the current behavior:
> 
> When a navigation occurs, the mojo::URLLoaderClient interface is first
> bound to the content::NavigationURLLoaderImpl in the browser process.
> When the browser knows in which renderer process the navigation will
> commit, the interface is bound to the content::URLLoaderClientImpl in
> the renderer process to continue the navigation. The switching from one
> to another happens when mojo::URLLoaderClient::OnReceiveResponse() is
> called. This is described here: https://goo.gl/Rrrc7n
> 
> # What are we trying to do:
> 
> After the mojo::URLLoaderClient interface is unbound in the browser
> process and bound again in the renderer process, it takes some amount of
> time to receive URLLoader::OnStartLoadingResponseBody(). It may be worth
> sending the data pipe with RenderFrameHostImpl::CommitNavigation() and
> give it to the renderer process immediatly instead of waiting for it. It
> would allow the Renderer process to get the main resource's data
> earlier, especially when the renderer process is busy.
> 
> Note: It doesn't look like there are any strong reasons to make
>       URLLoaderClient::OnReceiveResponse(response_head) and
>       URLLoaderClient::OnStartLoadingResponseBody(response_body)
>       separate messages, maybe at some point, they could be merged into:
>       URLLoaderClient::OnReceiveResponse(response_head, response_body)
> 
> # What this CL does:
> 
> This CL makes the switch to happen in
> URLLoaderClient::OnStartLoadingResponseBody(). The data pipe is
> transmitted in CommitNavigation().
> 
> This is enabled/disabled using the NavigationImmediateResponse experiment
> The goal is to look for performance improvement or regressions on
> Canary.
> 
> Bug: 831155
> Change-Id: Id6cf667fdc1482baf27f41aab754e58d9a5a569b
> Reviewed-on: https://chromium-review.googlesource.com/1100830
> Reviewed-by: Yutaka Hirano <[email protected]>
> Reviewed-by: Peter Kasting <[email protected]>
> Reviewed-by: Kinuko Yasuda <[email protected]>
> Commit-Queue: Arthur Sonzogni <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#573276}

[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]

Change-Id: I22eac2d660f9cf1d8128331b547c304af729a85a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 831155
Reviewed-on: https://chromium-review.googlesource.com/1129659
Reviewed-by: Philip Rogers <[email protected]>
Commit-Queue: Philip Rogers <[email protected]>
Cr-Commit-Position: refs/heads/master@{#573392}
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc
index b62b588b..0cd03e5 100644
--- a/content/browser/loader/navigation_url_loader_impl.cc
+++ b/content/browser/loader/navigation_url_loader_impl.cc
@@ -54,7 +54,6 @@
 #include "content/public/browser/resource_dispatcher_host_delegate.h"
 #include "content/public/browser/ssl_status.h"
 #include "content/public/browser/url_loader_request_interceptor.h"
-#include "content/public/common/browser_side_navigation_policy.h"
 #include "content/public/common/content_features.h"
 #include "content/public/common/referrer.h"
 #include "content/public/common/url_constants.h"
@@ -913,15 +912,6 @@
  private:
   // network::mojom::URLLoaderClient implementation:
   void OnReceiveResponse(const network::ResourceResponseHead& head) override {
-    // When NavigationImmediateResponseBody is enabled, wait for
-    // DidStartLoadingResponseBody() before sending anything to the renderer
-    // process.
-    if (IsNavigationImmediateResponseBodyEnabled() &&
-        !IsLoaderInterceptionEnabled() && !response_body_.is_valid()) {
-      head_ = head;
-      return;
-    }
-
     received_response_ = true;
 
     // If the default loader (network) was used to handle the URL load request
@@ -1076,11 +1066,11 @@
     // response. https://crbug.com/416050
     BrowserThread::PostTask(
         BrowserThread::UI, FROM_HERE,
-        base::BindOnce(
-            &NavigationURLLoaderImpl::OnReceiveResponse, owner_,
-            response->DeepCopy(), std::move(url_loader_client_endpoints),
-            std::move(response_body_), std::move(cloned_navigation_data),
-            global_request_id_, is_download, is_stream));
+        base::BindOnce(&NavigationURLLoaderImpl::OnReceiveResponse, owner_,
+                       response->DeepCopy(),
+                       std::move(url_loader_client_endpoints),
+                       std::move(cloned_navigation_data), global_request_id_,
+                       is_download, is_stream));
   }
 
   void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
@@ -1118,19 +1108,10 @@
   void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override {}
   void OnTransferSizeUpdated(int32_t transfer_size_diff) override {}
 
-  void OnStartLoadingResponseBody(
-      mojo::ScopedDataPipeConsumerHandle response_body) override {
-    // When NavigationImmediateResponseBody is disabled, this is not reached.
-    // At this point, the loader and client endpoints must have been unbound and
-    // forwarded to the renderer.
-    CHECK(IsNavigationImmediateResponseBodyEnabled());
-
-    // When NavigationImmediateResponseBody is enabled, the NavigationURLLoader
-    // waits for OnStartLoadingResponseBody() instead of OnReceiveResponse()
-    // before delegating the load to an URLLoaderClientImpl in the renderer
-    // process.
-    response_body_ = std::move(response_body);
-    OnReceiveResponse(head_);
+  void OnStartLoadingResponseBody(mojo::ScopedDataPipeConsumerHandle) override {
+    // Not reached. At this point, the loader and client endpoints must have
+    // been unbound and forwarded to the renderer.
+    CHECK(false);
   }
 
   void OnComplete(const network::URLLoaderCompletionStatus& status) override {
@@ -1300,9 +1281,6 @@
   // protocol handlers.
   std::set<std::string> known_schemes_;
 
-  network::ResourceResponseHead head_;
-  mojo::ScopedDataPipeConsumerHandle response_body_;
-
   mutable base::WeakPtrFactory<URLLoaderRequestController> weak_factory_;
 
   DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController);
@@ -1466,7 +1444,6 @@
 void NavigationURLLoaderImpl::OnReceiveResponse(
     scoped_refptr<network::ResourceResponse> response,
     network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints,
-    mojo::ScopedDataPipeConsumerHandle response_body,
     std::unique_ptr<NavigationData> navigation_data,
     const GlobalRequestID& global_request_id,
     bool is_download,
@@ -1479,7 +1456,7 @@
 
   delegate_->OnResponseStarted(
       std::move(response), std::move(url_loader_client_endpoints),
-      std::move(response_body), std::move(navigation_data), global_request_id,
+      std::move(navigation_data), global_request_id,
       allow_download_ && is_download, is_stream,
       request_controller_->TakeSubresourceLoaderParams());
 }