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

Unified Diff: content/browser/service_worker/service_worker_version.cc

Issue 2936623002: Implement dumb URLLoader{Factory} for ServiceWorker script loading (for try)
Patch Set: . Created 3 years, 6 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/service_worker/service_worker_version.cc
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc
index 306710a8ca16c874b225c158da2ed44dc34218af..ac6eb2a42eadf248a912bf3ef461c299aff70b74 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -846,6 +846,9 @@ ServiceWorkerVersion::PendingRequest::~PendingRequest() {}
void ServiceWorkerVersion::OnThreadStarted() {
DCHECK_EQ(EmbeddedWorkerStatus::STARTING, running_status());
+ DCHECK(provider_host_);
+ provider_host_->SetReadyToSendMessagesToWorker(
+ embedded_worker()->thread_id());
// Activate ping/pong now that JavaScript execution will start.
ping_controller_->Activate();
}
@@ -855,6 +858,11 @@ void ServiceWorkerVersion::OnStarting() {
observer.OnRunningStateChanged(this);
}
+void ServiceWorkerVersion::OnStartWorkerMessageSent() {
+ DCHECK(pending_provider_host_);
+ context()->AddProviderHost(std::move(pending_provider_host_));
+}
+
void ServiceWorkerVersion::OnStarted() {
DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status());
RestartTick(&idle_time_);
@@ -903,14 +911,7 @@ void ServiceWorkerVersion::OnDetached(EmbeddedWorkerStatus old_status) {
}
void ServiceWorkerVersion::OnScriptLoaded() {
- DCHECK(GetMainScriptHttpResponseInfo() ||
- // TODO(scottmg|falken): This DCHECK is currently triggered in
- // --network-service because ServiceWorkerReadFromCacheJob isn't being
- // used to retrieve the service worker js. This should be removed once
- // that's done.
- (IsBrowserSideNavigationEnabled() &&
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableNetworkService)));
+ DCHECK(GetMainScriptHttpResponseInfo());
if (IsInstalled(status()))
UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", true);
}
@@ -1465,6 +1466,11 @@ void ServiceWorkerVersion::StartWorkerInternal() {
StartTimeoutTimer();
+ DCHECK(!pending_provider_host_);
+ pending_provider_host_ =
+ ServiceWorkerProviderHost::PreCreateForController(this, context());
+ provider_host_ = pending_provider_host_->AsWeakPtr();
+
auto params = base::MakeUnique<EmbeddedWorkerStartParams>();
params->service_worker_version_id = version_id_;
params->scope = scope_;
@@ -1473,7 +1479,8 @@ void ServiceWorkerVersion::StartWorkerInternal() {
params->pause_after_download = pause_after_download_;
embedded_worker_->Start(
- std::move(params), mojo::MakeRequest(&event_dispatcher_),
+ std::move(params), pending_provider_host_->AsWeakPtr(),
+ mojo::MakeRequest(&event_dispatcher_),
base::Bind(&ServiceWorkerVersion::OnStartSentAndScriptEvaluated,
weak_factory_.GetWeakPtr()));
event_dispatcher_.set_connection_error_handler(base::Bind(

Powered by Google App Engine
This is Rietveld 408576698