Commit 2695d04d authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

PlzNavigate: Use the NavigationUrlLoaderNetworkService.

Use the NavigationURLLoaderNetworkService when NavigationMojoResponse is
enabled, even if the network service isn’t.

The feature NavigationMojoResponse is currently disabled by default, so
this patch shouldn't introduce any new regression.

See the others CLs in this series:
[1/3] https://chromium-review.googlesource.com/c/739502
[2/3] this CL.
[3/3] https://chromium-review.googlesource.com/c/753738

This is part 2 of the implementation plan.
Design doc: https://goo.gl/Rrrc7n

Bug: 705744
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo;master.tryserver.chromium.linux:linux_site_isolation
Change-Id: Ia95527dce4be7b43747fec09ffe61bc51b2195a6
Reviewed-on: https://chromium-review.googlesource.com/741237
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523373}
parent 70340ce0
......@@ -582,4 +582,205 @@ IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBaseBrowserTest,
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
}
// TODO(arthursonzogni): Remove these tests once NavigationMojoResponse has
// launched.
class NavigationMojoResponseBrowserTest : public ContentBrowserTest {
public:
NavigationMojoResponseBrowserTest() {}
protected:
void SetUp() override {
base::test::ScopedFeatureList().InitAndEnableFeature(
features::kNavigationMojoResponse);
ContentBrowserTest::SetUp();
}
void SetUpOnMainThread() override {
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(embedded_test_server()->Start());
}
};
// Ensure that browser initiated basic navigations work with browser side
// navigation.
// TODO(arthursonzogni): Remove this test once NavigationMojoResponse has
// launched.
IN_PROC_BROWSER_TEST_F(NavigationMojoResponseBrowserTest,
BrowserInitiatedNavigations) {
// Perform a navigation with no live renderer.
{
TestNavigationObserver observer(shell()->web_contents());
GURL url(embedded_test_server()->GetURL("/title1.html"));
NavigateToURL(shell(), url);
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
RenderFrameHost* initial_rfh =
static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host();
// Perform a same site navigation.
{
TestNavigationObserver observer(shell()->web_contents());
GURL url(embedded_test_server()->GetURL("/title2.html"));
NavigateToURL(shell(), url);
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
// The RenderFrameHost should not have changed.
EXPECT_EQ(initial_rfh, static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host());
// Perform a cross-site navigation.
{
TestNavigationObserver observer(shell()->web_contents());
GURL url = embedded_test_server()->GetURL("foo.com", "/title3.html");
NavigateToURL(shell(), url);
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
// The RenderFrameHost should have changed.
EXPECT_NE(initial_rfh, static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host());
}
// Ensure that renderer initiated same-site navigations work with browser side
// navigation.
// TODO(arthursonzogni): Remove this test once NavigationMojoResponse has
// launched.
IN_PROC_BROWSER_TEST_F(NavigationMojoResponseBrowserTest,
RendererInitiatedSameSiteNavigation) {
// Perform a navigation with no live renderer.
{
TestNavigationObserver observer(shell()->web_contents());
GURL url(embedded_test_server()->GetURL("/simple_links.html"));
NavigateToURL(shell(), url);
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
RenderFrameHost* initial_rfh =
static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host();
// Simulate clicking on a same-site link.
{
TestNavigationObserver observer(shell()->web_contents());
GURL url(embedded_test_server()->GetURL("/title2.html"));
bool success = false;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
shell(), "window.domAutomationController.send(clickSameSiteLink());",
&success));
EXPECT_TRUE(success);
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
// The RenderFrameHost should not have changed.
EXPECT_EQ(initial_rfh, static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host());
}
// Ensure that renderer initiated cross-site navigations work with browser side
// navigation.
// TODO(arthursonzogni): Remove this test once NavigationMojoResponse has
// launched.
IN_PROC_BROWSER_TEST_F(NavigationMojoResponseBrowserTest,
RendererInitiatedCrossSiteNavigation) {
// Perform a navigation with no live renderer.
{
TestNavigationObserver observer(shell()->web_contents());
GURL url(embedded_test_server()->GetURL("/simple_links.html"));
NavigateToURL(shell(), url);
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
RenderFrameHost* initial_rfh =
static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host();
// Simulate clicking on a cross-site link.
{
TestNavigationObserver observer(shell()->web_contents());
const char kReplacePortNumber[] =
"window.domAutomationController.send(setPortNumber(%d));";
uint16_t port_number = embedded_test_server()->port();
GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html");
bool success = false;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
shell(), base::StringPrintf(kReplacePortNumber, port_number),
&success));
success = false;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
shell(), "window.domAutomationController.send(clickCrossSiteLink());",
&success));
EXPECT_TRUE(success);
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
// The RenderFrameHost should not have changed unless site-per-process is
// enabled.
if (AreAllSitesIsolatedForTesting()) {
EXPECT_NE(initial_rfh,
static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host());
} else {
EXPECT_EQ(initial_rfh,
static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root()
->current_frame_host());
}
}
// Ensure that browser side navigation handles navigation failures.
// TODO(arthursonzogni): Remove this test once NavigationMojoResponse has
// launched.
IN_PROC_BROWSER_TEST_F(NavigationMojoResponseBrowserTest, FailedNavigation) {
// Perform a navigation with no live renderer.
{
TestNavigationObserver observer(shell()->web_contents());
GURL url(embedded_test_server()->GetURL("/title1.html"));
NavigateToURL(shell(), url);
EXPECT_EQ(url, observer.last_navigation_url());
EXPECT_TRUE(observer.last_navigation_succeeded());
}
// Now navigate to an unreachable url.
{
TestNavigationObserver observer(shell()->web_contents());
GURL error_url(
net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_RESET));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&net::URLRequestFailedJob::AddUrlHandler));
NavigateToURL(shell(), error_url);
EXPECT_EQ(error_url, observer.last_navigation_url());
NavigationEntry* entry =
shell()->web_contents()->GetController().GetLastCommittedEntry();
EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType());
}
}
} // namespace content
......@@ -14,6 +14,7 @@
#include "content/browser/loader/navigation_url_loader_network_service.h"
#include "content/browser/loader/url_loader_request_handler.h"
#include "content/public/browser/navigation_ui_data.h"
#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/content_features.h"
namespace content {
......@@ -33,7 +34,8 @@ std::unique_ptr<NavigationURLLoader> NavigationURLLoader::Create(
resource_context, storage_partition, std::move(request_info),
std::move(navigation_ui_data), service_worker_handle, delegate);
}
if (base::FeatureList::IsEnabled(features::kNetworkService)) {
if (base::FeatureList::IsEnabled(features::kNetworkService) ||
IsNavigationMojoResponseEnabled()) {
return std::make_unique<NavigationURLLoaderNetworkService>(
resource_context, storage_partition, std::move(request_info),
std::move(navigation_ui_data), service_worker_handle, appcache_handle,
......
......@@ -54,7 +54,8 @@ void NavigationURLLoaderImplCore::Start(
ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
resource_context, url_request_context_getter->GetURLRequestContext(),
upload_file_system_context, *request_info,
std::move(navigation_ui_data), this, service_worker_handle_core,
std::move(navigation_ui_data), this, mojom::URLLoaderClientPtr(),
mojom::URLLoaderRequest(), service_worker_handle_core,
appcache_handle_core);
}
......
......@@ -19,6 +19,7 @@
#include "content/browser/loader/navigation_resource_handler.h"
#include "content/browser/loader/navigation_resource_throttle.h"
#include "content/browser/loader/navigation_url_loader_delegate.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/loader/url_loader_request_handler.h"
#include "content/browser/resource_context_impl.h"
#include "content/browser/service_worker/service_worker_navigation_handle.h"
......@@ -39,6 +40,7 @@
#include "content/public/browser/navigation_ui_data.h"
#include "content/public/browser/ssl_status.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/common/content_features.h"
#include "content/public/common/referrer.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_loader_factory.mojom.h"
......@@ -172,12 +174,74 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
resource_context_(resource_context),
default_url_loader_factory_getter_(default_url_loader_factory_getter),
owner_(owner),
response_loader_binding_(this) {}
response_loader_binding_(this),
weak_factory_(this) {}
~URLLoaderRequestController() override {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
}
void CreateNonNetworkServiceURLLoader(
net::URLRequestContextGetter* url_request_context_getter,
storage::FileSystemContext* upload_file_system_context,
std::unique_ptr<NavigationRequestInfo> request_info,
std::unique_ptr<NavigationUIData> navigation_ui_data,
ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core,
AppCacheNavigationHandleCore* appcache_handle_core,
mojom::URLLoaderRequest url_loader,
mojom::URLLoaderClientPtr url_loader_client) {
DCHECK(!base::FeatureList::IsEnabled(features::kNetworkService));
DCHECK_CURRENTLY_ON(BrowserThread::IO);
// The ResourceDispatcherHostImpl can be null in unit tests.
if (ResourceDispatcherHostImpl::Get()) {
ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
resource_context_, url_request_context_getter->GetURLRequestContext(),
upload_file_system_context, *request_info,
std::move(navigation_ui_data), nullptr, std::move(url_loader_client),
std::move(url_loader), service_worker_navigation_handle_core,
appcache_handle_core);
}
// TODO(arthursonzogni): Detect when the ResourceDispatcherHost didn't
// create a URLLoader. When it doesn't, do not send OnRequestStarted().
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&NavigationURLLoaderNetworkService::OnRequestStarted,
owner_, base::TimeTicks::Now()));
}
// TODO(arthursonzogni): See if this could eventually be unified with Start().
void StartWithoutNetworkService(
net::URLRequestContextGetter* url_request_context_getter,
storage::FileSystemContext* upload_file_system_context,
ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core,
AppCacheNavigationHandleCore* appcache_handle_core,
std::unique_ptr<NavigationRequestInfo> request_info,
std::unique_ptr<NavigationUIData> navigation_ui_data) {
DCHECK(!base::FeatureList::IsEnabled(features::kNetworkService));
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!started_);
started_ = true;
StartLoaderCallback create_url_loader = base::BindOnce(
&URLLoaderRequestController::CreateNonNetworkServiceURLLoader,
weak_factory_.GetWeakPtr(),
base::Unretained(url_request_context_getter),
base::Unretained(upload_file_system_context), std::move(request_info),
std::move(navigation_ui_data),
base::Unretained(service_worker_navigation_handle_core),
base::Unretained(appcache_handle_core));
url_loader_ = ThrottlingURLLoader::CreateLoaderAndStart(
std::move(create_url_loader),
std::vector<std::unique_ptr<content::URLLoaderThrottle>>(),
/* routing_id = */ -1,
ResourceRequest(), // not used
/* client = */ this, kNavigationUrlLoaderTrafficAnnotation,
base::ThreadTaskRunnerHandle::Get());
}
void Start(
ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core,
AppCacheNavigationHandleCore* appcache_handle_core,
......@@ -185,6 +249,7 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
mojom::URLLoaderFactoryPtrInfo factory_for_webui,
int frame_tree_node_id,
std::unique_ptr<service_manager::Connector> connector) {
DCHECK(base::FeatureList::IsEnabled(features::kNetworkService));
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!started_);
frame_tree_node_id_ = frame_tree_node_id;
......@@ -247,6 +312,7 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
// This could be called multiple times to follow a chain of redirects.
void Restart() {
DCHECK(base::FeatureList::IsEnabled(features::kNetworkService));
// Clear |url_loader_| if it's not the default one (network). This allows
// the restarted request to use a new loader, instead of, e.g., reusing the
// AppCache or service worker loader. For an optimization, we keep and reuse
......@@ -265,6 +331,7 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
// if the |handler| wants to handle the request.
void MaybeStartLoader(URLLoaderRequestHandler* handler,
StartLoaderCallback start_loader_callback) {
DCHECK(base::FeatureList::IsEnabled(features::kNetworkService));
if (start_loader_callback) {
// |handler| wants to handle the request.
DCHECK(handler);
......@@ -355,9 +422,17 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
void FollowRedirect() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(url_loader_);
DCHECK(!response_url_loader_);
DCHECK(!redirect_info_.new_url.is_empty());
DCHECK(!response_url_loader_);
DCHECK(url_loader_);
// TODO(arthursonzogni): We might need to go through the rest of the
// function once there are several types of URLLoader handling the
// navigation, even in non network-service mode.
if (!base::FeatureList::IsEnabled(features::kNetworkService)) {
url_loader_->FollowRedirect();
return;
}
// Update resource_request_ and call Restart to give our handlers_ a chance
// at handling the new location. If no handler wants to take over, we'll
......@@ -401,6 +476,7 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
const base::Optional<net::SSLInfo>& ssl_info,
mojom::DownloadedTempFilePtr downloaded_file) override {
received_response_ = true;
// If the default loader (network) was used to handle the URL load request
// we need to see if the handlers want to potentially create a new loader
// for the response. e.g. AppCache.
......@@ -491,6 +567,7 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
return;
}
status_ = status;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&NavigationURLLoaderNetworkService::OnComplete, owner_,
......@@ -500,6 +577,9 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
// Returns true if a handler wants to handle the response, i.e. return a
// different response. For e.g. AppCache may have fallback content.
bool MaybeCreateLoaderForResponse(const ResourceResponseHead& response) {
if (!base::FeatureList::IsEnabled(features::kNetworkService))
return false;
if (!default_loader_used_)
return false;
......@@ -527,7 +607,9 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
base::Callback<WebContents*()> web_contents_getter_;
scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_;
mojom::URLLoaderFactoryPtr webui_factory_ptr_;
std::unique_ptr<ThrottlingURLLoader> url_loader_;
BlobHandles blob_handles_;
std::vector<GURL> url_chain_;
......@@ -567,6 +649,8 @@ class NavigationURLLoaderNetworkService::URLLoaderRequestController
// body to download code.
base::Optional<network::URLLoaderCompletionStatus> status_;
base::WeakPtrFactory<URLLoaderRequestController> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController);
};
......@@ -593,6 +677,36 @@ NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService(
request_info->common_params.navigation_start, "FrameTreeNode id",
frame_tree_node_id);
ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core =
service_worker_navigation_handle
? service_worker_navigation_handle->core()
: nullptr;
AppCacheNavigationHandleCore* appcache_handle_core =
appcache_handle ? appcache_handle->core() : nullptr;
if (!base::FeatureList::IsEnabled(features::kNetworkService)) {
DCHECK(!request_controller_);
request_controller_ = std::make_unique<URLLoaderRequestController>(
/* initial_handlers = */
std::vector<std::unique_ptr<URLLoaderRequestHandler>>(),
/* resource_request = */ nullptr, resource_context,
/* default_url_factory_getter = */ nullptr, weak_factory_.GetWeakPtr());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(
&URLLoaderRequestController::StartWithoutNetworkService,
base::Unretained(request_controller_.get()),
base::Unretained(storage_partition->GetURLRequestContext()),
base::Unretained(storage_partition->GetFileSystemContext()),
base::Unretained(service_worker_navigation_handle_core),
base::Unretained(appcache_handle_core),
base::Passed(std::move(request_info)),
base::Passed(std::move(navigation_ui_data))));
return;
}
// TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here.
auto new_request = std::make_unique<ResourceRequest>();
......@@ -660,10 +774,8 @@ NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&URLLoaderRequestController::Start,
base::Unretained(request_controller_.get()),
service_worker_navigation_handle
? service_worker_navigation_handle->core()
: nullptr,
appcache_handle ? appcache_handle->core() : nullptr,
base::Unretained(service_worker_navigation_handle_core),
base::Unretained(appcache_handle_core),
base::Passed(std::move(request_info)),
base::Passed(std::move(factory_for_webui)),
frame_tree_node_id,
......@@ -751,6 +863,12 @@ void NavigationURLLoaderNetworkService::OnComplete(
status.ssl_info);
}
void NavigationURLLoaderNetworkService::OnRequestStarted(
base::TimeTicks timestamp) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
delegate_->OnRequestStarted(timestamp);
}
void NavigationURLLoaderNetworkService::BindNonNetworkURLLoaderFactoryRequest(
const GURL& url,
mojom::URLLoaderFactoryRequest factory) {
......
......@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "content/browser/loader/navigation_url_loader.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/ssl_status.h"
......@@ -57,6 +58,7 @@ class CONTENT_EXPORT NavigationURLLoaderNetworkService
private:
class URLLoaderRequestController;
void OnRequestStarted(base::TimeTicks timestamp);
void BindNonNetworkURLLoaderFactoryRequest(
const GURL& url,
......
......@@ -1558,7 +1558,8 @@ ResourceDispatcherHostImpl::AddStandardHandlers(
handler.reset(new ThrottlingResourceHandler(
std::move(handler), request, std::move(post_mime_sniffing_throttles)));
if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) {
if (IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type) &&
!IsNavigationMojoResponseEnabled()) {
DCHECK(navigation_loader_core);
DCHECK(stream_handle);
// PlzNavigate
......@@ -1999,12 +2000,18 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
const NavigationRequestInfo& info,
std::unique_ptr<NavigationUIData> navigation_ui_data,
NavigationURLLoaderImplCore* loader,
mojom::URLLoaderClientPtr url_loader_client,
mojom::URLLoaderRequest url_loader_request,
ServiceWorkerNavigationHandleCore* service_worker_handle_core,
AppCacheNavigationHandleCore* appcache_handle_core) {
// PlzNavigate: BeginNavigationRequest currently should only be used for the
// browser-side navigations project.
CHECK(IsBrowserSideNavigationEnabled());
DCHECK_EQ(IsNavigationMojoResponseEnabled(), !loader);
DCHECK_EQ(IsNavigationMojoResponseEnabled(), url_loader_client.is_bound());
DCHECK_EQ(IsNavigationMojoResponseEnabled(), url_loader_request.is_pending());
ResourceType resource_type = info.is_main_frame ?
RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
......@@ -2029,7 +2036,12 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
info.common_params.url,
resource_type,
resource_context))) {
if (IsNavigationMojoResponseEnabled()) {
url_loader_client->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_ABORTED));
} else {
loader->NotifyRequestFailed(false, net::ERR_ABORTED, base::nullopt);
}
return;
}
......@@ -2075,7 +2087,12 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
if (body) {
if (!GetBodyBlobDataHandles(body, resource_context, &blob_handles)) {
new_request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
if (IsNavigationMojoResponseEnabled()) {
url_loader_client->OnComplete(
network::URLLoaderCompletionStatus(net::ERR_ABORTED));
} else {
loader->NotifyRequestFailed(false, net::ERR_ABORTED, base::nullopt);
}
return;
}
new_request->set_upload(UploadDataStreamBuilder::Build(
......@@ -2153,19 +2170,26 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
new_request.get(), appcache_handle_core->host(), resource_type, false);
}
std::unique_ptr<ResourceHandler> handler;
std::unique_ptr<StreamHandle> stream_handle;
if (IsNavigationMojoResponseEnabled()) {
handler = std::make_unique<MojoAsyncResourceHandler>(
new_request.get(), this, std::move(url_loader_request),
std::move(url_loader_client), resource_type);
} else {
StreamContext* stream_context =
GetStreamContextForResourceContext(resource_context);
// Note: the stream should be created with immediate mode set to true to
// ensure that data read will be flushed to the reader as soon as it's
// available. Otherwise, we risk delaying transmitting the body of the
// resource to the renderer, which will delay parsing accordingly.
std::unique_ptr<ResourceHandler> handler(
new StreamResourceHandler(new_request.get(), stream_context->registry(),
new_request->url().GetOrigin(), true));
std::unique_ptr<StreamHandle> stream_handle =
static_cast<StreamResourceHandler*>(handler.get())
handler = std::make_unique<StreamResourceHandler>(
new_request.get(), stream_context->registry(),
new_request->url().GetOrigin(), true);
stream_handle = static_cast<StreamResourceHandler*>(handler.get())
->stream()
->CreateHandle();
}
// Safe to consider navigations as kNoCORS.
// TODO(davidben): Fix the dependency on child_id/route_id. Those are used
......
......@@ -270,6 +270,8 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl
const NavigationRequestInfo& info,
std::unique_ptr<NavigationUIData> navigation_ui_data,
NavigationURLLoaderImplCore* loader,
mojom::URLLoaderClientPtr url_loader_client,
mojom::URLLoaderRequest url_loader_request,
ServiceWorkerNavigationHandleCore* service_worker_handle_core,
AppCacheNavigationHandleCore* appcache_handle_core);
......
......@@ -57,6 +57,7 @@
-NavigationControllerBrowserTest.ErrorPageReplacement
-NavigationHandleImplBrowserTest.ErrorCodeOnRedirect
-NavigationHandleImplBrowserTest.RedirectToRendererDebugUrl
-NavigationMojoResponseBrowserTest.FailedNavigation
-PlzNavigateNavigationHandleImplBrowserTest.ErrorPageNetworkError
-PowerMonitorTest.TestGpuProcess
-PowerMonitorTest.TestRendererProcess
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment