Fix session restore with network service.
This involved:
-persisting cookies with network service
-converting the browser tests to work with the network service
Bug: 789644, 769401, 776589
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I70320d5550e433049a910c64f055c1809aecbff1
Reviewed-on: https://chromium-review.googlesource.com/818486
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: John Abd-El-Malek <[email protected]>
Cr-Commit-Position: refs/heads/master@{#523462}
diff --git a/content/public/test/url_loader_interceptor.cc b/content/public/test/url_loader_interceptor.cc
index 380243e..036ecf6 100644
--- a/content/public/test/url_loader_interceptor.cc
+++ b/content/public/test/url_loader_interceptor.cc
@@ -12,6 +12,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_features.h"
#include "content/public/common/url_loader.mojom.h"
+#include "net/http/http_util.h"
namespace content {
@@ -187,6 +188,28 @@
}
}
+void URLLoaderInterceptor::WriteResponse(const std::string& headers,
+ const std::string& body,
+ mojom::URLLoaderClient* client) {
+ net::HttpResponseInfo info;
+ info.headers = new net::HttpResponseHeaders(
+ net::HttpUtil::AssembleRawHeaders(headers.c_str(), headers.length()));
+ content::ResourceResponseHead response;
+ response.headers = info.headers;
+ response.headers->GetMimeType(&response.mime_type);
+ client->OnReceiveResponse(response, base::nullopt, nullptr);
+
+ uint32_t bytes_written = body.size();
+ mojo::DataPipe data_pipe;
+ data_pipe.producer_handle->WriteData(body.data(), &bytes_written,
+ MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
+ client->OnStartLoadingResponseBody(std::move(data_pipe.consumer_handle));
+
+ network::URLLoaderCompletionStatus status;
+ status.error_code = net::OK;
+ client->OnComplete(status);
+}
+
void URLLoaderInterceptor::CreateURLLoaderFactoryForSubresources(
mojom::URLLoaderFactoryRequest request,
int process_id,