Commit 44c2c323 authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

Create S13nServiceWorker related objects without network service

When ServiceWorkerServicification is enabled, this CL is to make
ServiceWorkerURLLoaderJob and ServiceWorkerSubresourceLoader work without
NetworkService. This CL tries to create an URLLoaderRequestHandler for a service
worker (ServiceWorkerControlleeRequestHandler) even if no NetworkService flag.

ServiceWorkerServicification still doesn't work since
ServiceWorkerURLLoaderJob::ProceedWithResponse() hasn't been implemented yet.

Bug: 752394
Change-Id: I808346f248bba254e20e708d372dde46ecc103fe
Reviewed-on: https://chromium-review.googlesource.com/888361Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547053}
parent 235e9888
......@@ -4,6 +4,7 @@
#include "content/browser/frame_host/navigation_request_info.h"
#include "content/common/service_worker/service_worker_types.h"
#include "mojo/common/values_struct_traits.h"
namespace content {
......@@ -29,6 +30,18 @@ NavigationRequestInfo::NavigationRequestInfo(
report_raw_headers(report_raw_headers),
is_prerendering(is_prerendering) {}
NavigationRequestInfo::NavigationRequestInfo(const NavigationRequestInfo& other)
: common_params(other.common_params),
begin_params(other.begin_params.Clone()),
site_for_cookies(other.site_for_cookies),
is_main_frame(other.is_main_frame),
parent_is_main_frame(other.parent_is_main_frame),
are_ancestors_secure(other.are_ancestors_secure),
frame_tree_node_id(other.frame_tree_node_id),
is_for_guests_only(other.is_for_guests_only),
report_raw_headers(other.report_raw_headers),
is_prerendering(other.is_prerendering) {}
NavigationRequestInfo::~NavigationRequestInfo() {}
} // namespace content
......@@ -31,6 +31,7 @@ struct CONTENT_EXPORT NavigationRequestInfo {
bool is_for_guests_only,
bool report_raw_headers,
bool is_prerendering);
NavigationRequestInfo(const NavigationRequestInfo& other);
~NavigationRequestInfo();
const CommonNavigationParams common_params;
......
......@@ -34,8 +34,7 @@ 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(network::features::kNetworkService) ||
IsNavigationMojoResponseEnabled()) {
if (IsNavigationMojoResponseEnabled()) {
return std::make_unique<NavigationURLLoaderNetworkService>(
resource_context, storage_partition, std::move(request_info),
std::move(navigation_ui_data), service_worker_handle, appcache_handle,
......
......@@ -321,6 +321,9 @@ void ServiceWorkerNavigationLoader::StartResponse(
// We have a non-redirect response. Send the headers to the client.
CommitResponseHeaders();
// S13nServiceWorker without NetworkService:
// TODO(shimazu): Wait to respond body until ProceedWithResponse().
// Handle a stream response body.
if (!body_as_stream.is_null() && body_as_stream->stream.is_valid()) {
stream_waiter_ = std::make_unique<StreamWaiter>(
......
......@@ -86,6 +86,15 @@ void ServiceWorkerRequestHandler::InitializeForNavigation(
const base::Callback<WebContents*(void)>& web_contents_getter) {
CHECK(IsBrowserSideNavigationEnabled());
// S13nServiceWorker enabled, NetworkService disabled:
// To start the navigation, InitializeForNavigationNetworkService() is called
// instead of this, but when that request handler falls back to network,
// InitializeForNavigation() is called.
// Since we already determined to fall back to network, don't create another
// handler.
if (ServiceWorkerUtils::IsServicificationEnabled())
return;
// Only create a handler when there is a ServiceWorkerNavigationHandlerCore
// to take ownership of a pre-created SeviceWorkerProviderHost.
if (!navigation_handle_core)
......
......@@ -28,6 +28,7 @@
#include "content/browser/loader/prefetch_url_loader_service.h"
#include "content/browser/notifications/platform_notification_context_impl.h"
#include "content/common/dom_storage/dom_storage_types.h"
#include "content/common/service_worker/service_worker_utils.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
......@@ -667,7 +668,8 @@ std::unique_ptr<StoragePartitionImpl> StoragePartitionImpl::Create(
scoped_refptr<ChromeBlobStorageContext> blob_context =
ChromeBlobStorageContext::GetFor(context);
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
if (base::FeatureList::IsEnabled(network::features::kNetworkService) ||
ServiceWorkerUtils::IsServicificationEnabled()) {
BlobURLLoaderFactory::BlobContextGetter blob_getter =
base::BindOnce(&BlobStorageContextGetterForStorage, blob_context);
partition->blob_url_loader_factory_ =
......
......@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "services/network/public/cpp/features.h"
namespace content {
......@@ -23,7 +24,10 @@ bool IsNavigationMojoResponseEnabled() {
return false;
return base::FeatureList::IsEnabled(features::kNavigationMojoResponse) ||
base::FeatureList::IsEnabled(features::kSignedHTTPExchange);
base::FeatureList::IsEnabled(
features::kServiceWorkerServicification) ||
base::FeatureList::IsEnabled(features::kSignedHTTPExchange) ||
base::FeatureList::IsEnabled(network::features::kNetworkService);
}
} // namespace content
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