Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Unified Diff: content/browser/loader/navigation_url_loader_network_service.cc

Issue 2847003003: Fix SitePerProcessBrowserTest.ProcessTransferAfterError to not requiring modifying the mock HostRes… (Closed)
Patch Set: remove unnecessary include Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/navigation_url_loader_network_service.cc
diff --git a/content/browser/loader/navigation_url_loader_network_service.cc b/content/browser/loader/navigation_url_loader_network_service.cc
index f6f5ba882512d4f27e875c51cbfcbddd355fe704..11e104a443a88b19acc99c4f50197a22192bfca7 100644
--- a/content/browser/loader/navigation_url_loader_network_service.cc
+++ b/content/browser/loader/navigation_url_loader_network_service.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/frame_host/navigation_request_info.h"
@@ -27,6 +28,11 @@
namespace content {
+namespace {
+static base::LazyInstance<mojom::URLLoaderFactoryPtr>::Leaky
+ g_url_loader_factory = LAZY_INSTANCE_INITIALIZER;
+}
+
// This function is called on the IO thread for POST/PUT requests for
// attaching blob information to the request body.
void HandleRequestsWithBody(
@@ -57,8 +63,12 @@ NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService(
// TODO(scottmg): Maybe some of this setup should be done only once, instead
// of every time.
- ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
- mojom::kNetworkServiceName, &url_loader_factory_);
+ if (g_url_loader_factory.Get().get()) {
+ url_loader_factory_ = std::move(g_url_loader_factory.Get());
+ } else {
+ ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
+ mojom::kNetworkServiceName, &url_loader_factory_);
+ }
// TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here.
auto new_request = base::MakeUnique<ResourceRequest>();
@@ -106,6 +116,11 @@ NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService(
NavigationURLLoaderNetworkService::~NavigationURLLoaderNetworkService() {}
+void NavigationURLLoaderNetworkService::OverrideURLLoaderFactoryForTesting(
+ mojom::URLLoaderFactoryPtr url_loader_factory) {
+ g_url_loader_factory.Get() = std::move(url_loader_factory);
+}
+
void NavigationURLLoaderNetworkService::FollowRedirect() {
url_loader_associated_ptr_->FollowRedirect();
}

Powered by Google App Engine
This is Rietveld 408576698