Commit f922da77 authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

Remove ServiceWorkerScriptStreaming flag

Bug: 807127
Change-Id: I29dc398b9b2809abc0d2eba7345d00aa03acfc9a
Reviewed-on: https://chromium-review.googlesource.com/920566
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537611}
parent de6d8dbb
......@@ -1650,10 +1650,6 @@ const FeatureEntry kFeatureEntries[] = {
{"trace-upload-url", flag_descriptions::kTraceUploadUrlName,
flag_descriptions::kTraceUploadUrlDescription, kOsAll,
MULTI_VALUE_TYPE(kTraceUploadURL)},
{"enable-service-worker-script-streaming",
flag_descriptions::kServiceWorkerScriptStreamingName,
flag_descriptions::kServiceWorkerScriptStreamingDescription, kOsAll,
FEATURE_VALUE_TYPE(features::kServiceWorkerScriptStreaming)},
{"enable-service-worker-script-full-code-cache",
flag_descriptions::kServiceWorkerScriptFullCodeCacheName,
flag_descriptions::kServiceWorkerScriptFullCodeCacheDescription, kOsAll,
......
......@@ -1313,12 +1313,6 @@ const char kServiceWorkerPaymentAppsName[] = "Service Worker payment apps";
const char kServiceWorkerPaymentAppsDescription[] =
"Enable Service Worker applications to integrate as payment apps";
const char kServiceWorkerScriptStreamingName[] =
"Service worker script streaming.";
const char kServiceWorkerScriptStreamingDescription[] =
"Installed scripts for a service worker are sent over a dedicated "
"message pipe and data pipes, and that is never be blocked on the main "
"thread.";
const char kServiceWorkerScriptFullCodeCacheName[] =
"Service worker script full code cache.";
......
......@@ -806,8 +806,6 @@ extern const char kServiceWorkerNavigationPreloadDescription[];
extern const char kServiceWorkerPaymentAppsName[];
extern const char kServiceWorkerPaymentAppsDescription[];
extern const char kServiceWorkerScriptStreamingName[];
extern const char kServiceWorkerScriptStreamingDescription[];
extern const char kServiceWorkerScriptFullCodeCacheName[];
extern const char kServiceWorkerScriptFullCodeCacheDescription[];
......
......@@ -110,25 +110,20 @@ bool ServiceWorkerScriptURLLoaderFactory::ShouldHandleScriptRequest(
// TODO: Make sure we don't handle the redirected request.
// If script streaming is enabled, for installed service workers, typically
// all the scripts are served via script streaming, so we don't come here.
// However, we still come here when the service worker is A) importing a
// script that was never installed, or B) loading the same script twice.
// For now, return false here to fallback to network. Eventually, A) should
// be deprecated (https://crbug.com/719052), and B) should be handled by
// script streaming as well, see the TODO in
// WebServiceWorkerInstalledScriptsManagerImpl::GetRawScriptData().
// For installed service workers, typically all the scripts are served via
// script streaming, so we don't come here. However, we still come here when
// the service worker is importing a script that was never installed. For now,
// return false here to fallback to network. Eventually, it should be
// deprecated (https://crbug.com/719052).
//
// When script streaming is not enabled, we get here even for the main
// For service workers that are not installed, we get here even for the main
// script. Therefore, ServiceWorkerScriptURLLoader must handle the request
// (even though it currently just does a network fetch for now), because it
// sets the main script's HTTP Response Info (via
// ServiceWorkerVersion::SetMainScriptHttpResponseInfo()) which otherwise
// would never be set.
if (ServiceWorkerVersion::IsInstalled(version->status()) &&
ServiceWorkerUtils::IsScriptStreamingEnabled()) {
if (ServiceWorkerVersion::IsInstalled(version->status()))
return false;
}
// TODO: Make sure we come here only for new / unknown scripts
// once script streaming manager in the renderer side stops sending
......
......@@ -226,11 +226,6 @@ class ServiceWorkerURLRequestJobTest
version_ = new ServiceWorkerVersion(
registration_.get(), GURL("https://example.com/service_worker.js"), 1L,
helper_->context()->AsWeakPtr());
// If script streaming is not enabled, SetMainScriptHttpResponseInfo()
// should be called manually since |http_info| which is stored in disk cache
// won't be read during SWVersion::StartWorker() in tests.
if (!ServiceWorkerUtils::IsScriptStreamingEnabled())
version_->SetMainScriptHttpResponseInfo(*http_info);
std::vector<ServiceWorkerDatabase::ResourceRecord> records;
records.push_back(WriteToDiskCacheWithCustomResponseInfoSync(
helper_->context()->storage(), version_->script_url(), 10,
......
......@@ -1504,8 +1504,7 @@ void ServiceWorkerVersion::StartWorkerInternal() {
params->is_installed = IsInstalled(status_);
params->pause_after_download = pause_after_download_;
if (ServiceWorkerUtils::IsScriptStreamingEnabled() && IsInstalled(status()) &&
!pause_after_download_) {
if (IsInstalled(status()) && !pause_after_download_) {
DCHECK(!installed_scripts_sender_);
installed_scripts_sender_ =
std::make_unique<ServiceWorkerInstalledScriptsSender>(this);
......
......@@ -292,9 +292,6 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
if (base::FeatureList::IsEnabled(features::kServiceWorkerPaymentApps))
WebRuntimeFeatures::EnablePaymentApp(true);
WebRuntimeFeatures::EnableServiceWorkerScriptStreaming(
base::FeatureList::IsEnabled(features::kServiceWorkerScriptStreaming));
WebRuntimeFeatures::EnableServiceWorkerScriptFullCodeCache(
base::FeatureList::IsEnabled(
features::kServiceWorkerScriptFullCodeCache));
......
......@@ -146,11 +146,6 @@ bool ServiceWorkerUtils::IsServicificationEnabled() {
return base::FeatureList::IsEnabled(network::features::kNetworkService);
}
// static
bool ServiceWorkerUtils::IsScriptStreamingEnabled() {
return base::FeatureList::IsEnabled(features::kServiceWorkerScriptStreaming);
}
// static
std::string ServiceWorkerUtils::ErrorTypeToString(
blink::mojom::ServiceWorkerErrorType error) {
......
......@@ -45,8 +45,6 @@ class ServiceWorkerUtils {
const GURL& script_url,
std::string* error_message);
CONTENT_EXPORT static bool IsScriptStreamingEnabled();
// Returns true if all members of |urls| have the same origin, and
// OriginCanAccessServiceWorkers is true for this origin.
// If --disable-web-security is enabled, the same origin check is
......
......@@ -314,10 +314,6 @@ const base::Feature kSendBeaconThrowForBlobWithNonSimpleType{
const base::Feature kServiceWorkerPaymentApps{
"ServiceWorkerPaymentApps", base::FEATURE_DISABLED_BY_DEFAULT};
// Streaming installed scripts on starting service workers.
const base::Feature kServiceWorkerScriptStreaming{
"ServiceWorkerScriptStreaming", base::FEATURE_ENABLED_BY_DEFAULT};
// Generate V8 full code cache of service worker scripts.
const base::Feature kServiceWorkerScriptFullCodeCache{
"ServiceWorkerScriptFullCodeCache", base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -82,7 +82,6 @@ CONTENT_EXPORT extern const base::Feature kScrollAnchorSerialization;
CONTENT_EXPORT
extern const base::Feature kSendBeaconThrowForBlobWithNonSimpleType;
CONTENT_EXPORT extern const base::Feature kServiceWorkerPaymentApps;
CONTENT_EXPORT extern const base::Feature kServiceWorkerScriptStreaming;
CONTENT_EXPORT extern const base::Feature kServiceWorkerScriptFullCodeCache;
CONTENT_EXPORT extern const base::Feature kSharedArrayBuffer;
CONTENT_EXPORT extern const base::Feature kSignedHTTPExchange;
......
......@@ -59,12 +59,10 @@ void EmbeddedWorkerInstanceClientImpl::StartWorker(
"EmbeddedWorkerInstanceClientImpl::StartWorker");
service_manager::mojom::InterfaceProviderPtr interface_provider(
std::move(params->provider_info->interface_provider));
const bool use_script_streaming =
ServiceWorkerUtils::IsScriptStreamingEnabled() &&
params->installed_scripts_info;
auto client = std::make_unique<ServiceWorkerContextClient>(
params->embedded_worker_id, params->service_worker_version_id,
params->scope, params->script_url, use_script_streaming,
params->scope, params->script_url,
!params->installed_scripts_info.is_null(),
std::move(params->dispatcher_request),
std::move(params->controller_request),
std::move(params->service_worker_host), std::move(params->instance_host),
......@@ -134,8 +132,7 @@ EmbeddedWorkerInstanceClientImpl::StartWorkerContext(
// |installed_scripts_info| is null if scripts should be served by net layer,
// when the worker is not installed, or the worker is launched for checking
// the update.
if (ServiceWorkerUtils::IsScriptStreamingEnabled() &&
params->installed_scripts_info) {
if (params->installed_scripts_info) {
manager = WebServiceWorkerInstalledScriptsManagerImpl::Create(
std::move(params->installed_scripts_info), io_thread_runner_);
}
......
......@@ -161,10 +161,8 @@ void WorkerGlobalScope::importScripts(const Vector<String>& urls,
String source_code;
std::unique_ptr<Vector<char>> cached_meta_data;
LoadResult result = LoadResult::kNotHandled;
if (RuntimeEnabledFeatures::ServiceWorkerScriptStreamingEnabled()) {
result = LoadingScriptFromInstalledScriptsManager(
complete_url, &response_url, &source_code, &cached_meta_data);
}
result = LoadingScriptFromInstalledScriptsManager(
complete_url, &response_url, &source_code, &cached_meta_data);
// If the script wasn't provided by the InstalledScriptsManager, load from
// ResourceLoader.
......
......@@ -101,8 +101,7 @@ WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(
pause_after_download_state_(kDontPauseAfterDownload),
waiting_for_debugger_state_(kNotWaitingForDebugger),
interface_provider_info_(std::move(interface_provider_info)) {
if (RuntimeEnabledFeatures::ServiceWorkerScriptStreamingEnabled() &&
installed_scripts_manager) {
if (installed_scripts_manager) {
installed_scripts_manager_ =
std::make_unique<ServiceWorkerInstalledScriptsManager>(
std::move(installed_scripts_manager));
......@@ -256,10 +255,11 @@ void WebEmbeddedWorkerImpl::OnShadowPageInitialized() {
shadow_page_->DocumentLoader()->SetServiceWorkerNetworkProvider(
worker_context_client_->CreateServiceWorkerNetworkProvider());
// Kickstart the worker before loading the script when the script has been
// installed.
if (RuntimeEnabledFeatures::ServiceWorkerScriptStreamingEnabled() &&
installed_scripts_manager_ &&
// If this is an installed service worker, we can start the worker thread
// now. The script will be streamed in by the installed scripts manager in
// parallel. For non-installed scripts, the script must be loaded from network
// before the worker thread can be started.
if (installed_scripts_manager_ &&
installed_scripts_manager_->IsScriptInstalled(
worker_start_data_.script_url)) {
DCHECK_EQ(pause_after_download_state_, kDontPauseAfterDownload);
......
......@@ -79,8 +79,7 @@ ServiceWorkerGlobalScope* ServiceWorkerGlobalScope::Create(
double time_origin) {
// If the script is being loaded via script streaming, the script is not yet
// loaded.
if (RuntimeEnabledFeatures::ServiceWorkerScriptStreamingEnabled() &&
thread->GetInstalledScriptsManager() &&
if (thread->GetInstalledScriptsManager() &&
thread->GetInstalledScriptsManager()->IsScriptInstalled(
creation_params->script_url)) {
// CSP headers, referrer policy, and origin trial tokens will be provided by
......@@ -110,8 +109,7 @@ void ServiceWorkerGlobalScope::EvaluateClassicScript(
// Receive the main script via script streaming if needed.
InstalledScriptsManager* installed_scripts_manager =
GetThread()->GetInstalledScriptsManager();
if (RuntimeEnabledFeatures::ServiceWorkerScriptStreamingEnabled() &&
installed_scripts_manager &&
if (installed_scripts_manager &&
installed_scripts_manager->IsScriptInstalled(script_url)) {
// GetScriptData blocks until the script is received from the browser.
InstalledScriptsManager::ScriptData script_data;
......
......@@ -116,11 +116,7 @@ class WebEmbeddedWorkerImplTest : public ::testing::Test {
auto installed_scripts_manager =
std::make_unique<MockServiceWorkerInstalledScriptsManager>();
mock_client_ = client.get();
if (RuntimeEnabledFeatures::ServiceWorkerScriptStreamingEnabled()) {
mock_installed_scripts_manager_ = installed_scripts_manager.get();
} else {
mock_installed_scripts_manager_ = nullptr;
}
mock_installed_scripts_manager_ = installed_scripts_manager.get();
worker_ = WebEmbeddedWorker::Create(
std::move(client), std::move(installed_scripts_manager),
mojo::ScopedMessagePipeHandle(), mojo::ScopedMessagePipeHandle());
......@@ -185,18 +181,13 @@ TEST_F(WebEmbeddedWorkerImplTest, TerminateWhileLoadingScript) {
// Load the shadow page.
EXPECT_CALL(*mock_client_, CreateServiceWorkerNetworkProviderProxy())
.WillOnce(::testing::Return(nullptr));
if (mock_installed_scripts_manager_) {
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(1)
.WillOnce(::testing::Return(false));
}
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
::testing::Mock::VerifyAndClearExpectations(mock_client_);
if (mock_installed_scripts_manager_) {
::testing::Mock::VerifyAndClearExpectations(
mock_installed_scripts_manager_);
}
::testing::Mock::VerifyAndClearExpectations(mock_installed_scripts_manager_);
// Terminate before loading the script.
EXPECT_CALL(*mock_client_, WorkerContextFailedToStart()).Times(1);
......@@ -214,18 +205,14 @@ TEST_F(WebEmbeddedWorkerImplTest, TerminateWhilePausedAfterDownload) {
// Load the shadow page.
EXPECT_CALL(*mock_client_, CreateServiceWorkerNetworkProviderProxy())
.WillOnce(::testing::Return(nullptr));
if (mock_installed_scripts_manager_) {
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(1)
.WillOnce(::testing::Return(false));
}
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
::testing::Mock::VerifyAndClearExpectations(mock_client_);
if (mock_installed_scripts_manager_) {
::testing::Mock::VerifyAndClearExpectations(
mock_installed_scripts_manager_);
}
::testing::Mock::VerifyAndClearExpectations(mock_installed_scripts_manager_);
// Load the script.
EXPECT_CALL(*mock_client_, WorkerScriptLoaded()).Times(1);
......@@ -258,18 +245,14 @@ TEST_F(WebEmbeddedWorkerImplTest, ScriptNotFound) {
// Load the shadow page.
EXPECT_CALL(*mock_client_, CreateServiceWorkerNetworkProviderProxy())
.WillOnce(::testing::Return(nullptr));
if (mock_installed_scripts_manager_) {
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(1)
.WillOnce(::testing::Return(false));
}
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
::testing::Mock::VerifyAndClearExpectations(mock_client_);
if (mock_installed_scripts_manager_) {
::testing::Mock::VerifyAndClearExpectations(
mock_installed_scripts_manager_);
}
::testing::Mock::VerifyAndClearExpectations(mock_installed_scripts_manager_);
// Load the script.
EXPECT_CALL(*mock_client_, WorkerScriptLoaded()).Times(0);
......@@ -294,37 +277,27 @@ TEST_F(WebEmbeddedWorkerImplTest, MAYBE_DontPauseAfterDownload) {
// Load the shadow page.
EXPECT_CALL(*mock_client_, CreateServiceWorkerNetworkProviderProxy())
.WillOnce(::testing::Return(nullptr));
if (mock_installed_scripts_manager_) {
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(1)
.WillOnce(::testing::Return(false));
}
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
::testing::Mock::VerifyAndClearExpectations(mock_client_);
if (mock_installed_scripts_manager_) {
::testing::Mock::VerifyAndClearExpectations(
mock_installed_scripts_manager_);
}
::testing::Mock::VerifyAndClearExpectations(mock_installed_scripts_manager_);
// Load the script.
EXPECT_CALL(*mock_client_, WorkerScriptLoaded()).Times(1);
EXPECT_CALL(*mock_client_, CreateServiceWorkerProviderProxy())
.WillOnce(::testing::Return(nullptr));
// This is called on the worker thread.
if (mock_installed_scripts_manager_) {
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(1)
.WillOnce(::testing::Return(false));
}
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
mock_client_->WaitUntilScriptEvaluated();
::testing::Mock::VerifyAndClearExpectations(mock_client_);
if (mock_installed_scripts_manager_) {
::testing::Mock::VerifyAndClearExpectations(
mock_installed_scripts_manager_);
}
::testing::Mock::VerifyAndClearExpectations(mock_installed_scripts_manager_);
// Terminate the running worker thread.
EXPECT_CALL(*mock_client_, WorkerContextFailedToStart()).Times(0);
......@@ -349,18 +322,13 @@ TEST_F(WebEmbeddedWorkerImplTest, MAYBE_PauseAfterDownload) {
// Load the shadow page.
EXPECT_CALL(*mock_client_, CreateServiceWorkerNetworkProviderProxy())
.WillOnce(::testing::Return(nullptr));
if (mock_installed_scripts_manager_) {
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(1)
.WillOnce(::testing::Return(false));
}
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
::testing::Mock::VerifyAndClearExpectations(mock_client_);
if (mock_installed_scripts_manager_) {
::testing::Mock::VerifyAndClearExpectations(
mock_installed_scripts_manager_);
}
::testing::Mock::VerifyAndClearExpectations(mock_installed_scripts_manager_);
// Load the script.
EXPECT_CALL(*mock_client_, WorkerScriptLoaded()).Times(1);
......@@ -372,19 +340,14 @@ TEST_F(WebEmbeddedWorkerImplTest, MAYBE_PauseAfterDownload) {
EXPECT_CALL(*mock_client_, CreateServiceWorkerProviderProxy())
.WillOnce(::testing::Return(nullptr));
// This is called on the worker thread.
if (mock_installed_scripts_manager_) {
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(1)
.WillOnce(::testing::Return(false));
}
EXPECT_CALL(*mock_installed_scripts_manager_,
IsScriptInstalled(start_data_.script_url))
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
worker_->ResumeAfterDownload();
mock_client_->WaitUntilScriptEvaluated();
::testing::Mock::VerifyAndClearExpectations(mock_client_);
if (mock_installed_scripts_manager_) {
::testing::Mock::VerifyAndClearExpectations(
mock_installed_scripts_manager_);
}
::testing::Mock::VerifyAndClearExpectations(mock_installed_scripts_manager_);
// Terminate the running worker thread.
EXPECT_CALL(*mock_client_, WorkerContextFailedToStart()).Times(0);
......
......@@ -382,10 +382,6 @@ void WebRuntimeFeatures::EnableScrollAnchorSerialization(bool enable) {
RuntimeEnabledFeatures::SetScrollAnchorSerializationEnabled(enable);
}
void WebRuntimeFeatures::EnableServiceWorkerScriptStreaming(bool enable) {
RuntimeEnabledFeatures::SetServiceWorkerScriptStreamingEnabled(enable);
}
void WebRuntimeFeatures::EnableServiceWorkerScriptFullCodeCache(bool enable) {
RuntimeEnabledFeatures::SetServiceWorkerScriptFullCodeCacheEnabled(enable);
}
......
......@@ -956,9 +956,6 @@
{
name: "ServiceWorkerScriptFullCodeCache",
},
{
name: "ServiceWorkerScriptStreaming",
},
{
name: "ServiceWorkerUpdateViaCache",
status: "experimental",
......
......@@ -130,7 +130,6 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableScrollAnchoring(bool);
BLINK_PLATFORM_EXPORT static void EnableScrollAnchorSerialization(bool);
BLINK_PLATFORM_EXPORT static void EnableServiceWorkerNavigationPreload(bool);
BLINK_PLATFORM_EXPORT static void EnableServiceWorkerScriptStreaming(bool);
BLINK_PLATFORM_EXPORT static void EnableServiceWorkerScriptFullCodeCache(
bool);
BLINK_PLATFORM_EXPORT static void EnableSharedArrayBuffer(bool);
......
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