Convert android_webview to use the URLResponseHead mojom types.

Bug: 984550
Change-Id: I2bf27ce77287394c782692483117ee105e214563
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1875385
Reviewed-by: Bo <boliu@chromium.org>
Commit-Queue: Lucas Gadani <lfg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708731}
diff --git a/android_webview/browser/network_service/android_stream_reader_url_loader.cc b/android_webview/browser/network_service/android_stream_reader_url_loader.cc
index e5164d64..9402725 100644
--- a/android_webview/browser/network_service/android_stream_reader_url_loader.cc
+++ b/android_webview/browser/network_service/android_stream_reader_url_loader.cc
@@ -100,8 +100,7 @@
     const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
     std::unique_ptr<ResponseDelegate> response_delegate)
     : resource_request_(resource_request),
-      resource_response_head_(
-          std::make_unique<network::ResourceResponseHead>()),
+      response_head_(network::mojom::URLResponseHead::New()),
       client_(std::move(client)),
       traffic_annotation_(traffic_annotation),
       response_delegate_(std::move(response_delegate)),
@@ -218,7 +217,7 @@
   // HttpResponseHeaders expects its input string to be terminated by two NULs.
   status.append("\0\0", 2);
 
-  network::ResourceResponseHead& head = *resource_response_head_;
+  network::mojom::URLResponseHead& head = *response_head_;
   head.request_start = base::TimeTicks::Now();
   head.response_start = base::TimeTicks::Now();
   head.headers = new net::HttpResponseHeaders(status);
@@ -286,7 +285,7 @@
   //    needs the ability to break the stream after getting the headers but
   //    before finishing the read.
   if (!base::FeatureList::IsEnabled(features::kWebViewSniffMimeType) ||
-      !resource_response_head_->mime_type.empty()) {
+      !response_head_->mime_type.empty()) {
     SendResponseToClient();
   }
   ReadMore();
@@ -295,8 +294,7 @@
 void AndroidStreamReaderURLLoader::SendResponseToClient() {
   DCHECK(consumer_handle_.is_valid());
   DCHECK(client_.is_bound());
-  client_->OnReceiveResponse(*resource_response_head_);
-  resource_response_head_ = nullptr;
+  client_->OnReceiveResponse(std::move(response_head_));
   client_->OnStartLoadingResponseBody(std::move(consumer_handle_));
 }
 
@@ -360,7 +358,7 @@
     // We only hit this on for the first buffer read, which we expect to be
     // enough to determine the MIME type.
     DCHECK(base::FeatureList::IsEnabled(features::kWebViewSniffMimeType));
-    if (resource_response_head_->mime_type.empty()) {
+    if (response_head_->mime_type.empty()) {
       // Limit sniffing to the first net::kMaxBytesToSniff.
       size_t data_length = result;
       if (data_length > net::kMaxBytesToSniff)
@@ -373,8 +371,8 @@
       // SniffMimeType() returns false if there is not enough data to
       // determine the mime type. However, even if it returns false, it
       // returns a new type that is probably better than the current one.
-      resource_response_head_->mime_type.assign(new_type);
-      resource_response_head_->did_mime_sniff = true;
+      response_head_->mime_type.assign(new_type);
+      response_head_->did_mime_sniff = true;
     }
 
     SendResponseToClient();
diff --git a/android_webview/browser/network_service/android_stream_reader_url_loader.h b/android_webview/browser/network_service/android_stream_reader_url_loader.h
index cd77346d..856535f5 100644
--- a/android_webview/browser/network_service/android_stream_reader_url_loader.h
+++ b/android_webview/browser/network_service/android_stream_reader_url_loader.h
@@ -9,8 +9,8 @@
 #include "mojo/public/cpp/system/simple_watcher.h"
 #include "net/http/http_byte_range.h"
 #include "services/network/public/cpp/net_adapters.h"
-#include "services/network/public/cpp/resource_response.h"
 #include "services/network/public/mojom/url_loader.mojom.h"
+#include "services/network/public/mojom/url_response_head.mojom.h"
 
 namespace android_webview {
 
@@ -107,7 +107,7 @@
 
   net::HttpByteRange byte_range_;
   network::ResourceRequest resource_request_;
-  std::unique_ptr<network::ResourceResponseHead> resource_response_head_;
+  network::mojom::URLResponseHeadPtr response_head_;
   network::mojom::URLLoaderClientPtr client_;
   const net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
   std::unique_ptr<ResponseDelegate> response_delegate_;