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

Side by Side Diff: content/browser/service_worker/service_worker_register_job.cc

Issue 962543005: Service Worker: Add metrics and timeout for starting a Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync again Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_register_job.h" 5 #include "content/browser/service_worker/service_worker_register_job.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/service_worker/service_worker_context_core.h" 10 #include "content/browser/service_worker/service_worker_context_core.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 case net::ERR_ABORTED: 347 case net::ERR_ABORTED:
348 status = SERVICE_WORKER_ERROR_ABORT; 348 status = SERVICE_WORKER_ERROR_ABORT;
349 break; 349 break;
350 default: 350 default:
351 status = SERVICE_WORKER_ERROR_NETWORK; 351 status = SERVICE_WORKER_ERROR_NETWORK;
352 } 352 }
353 message = new_version()->script_cache_map()->main_script_status_message(); 353 message = new_version()->script_cache_map()->main_script_status_message();
354 if (message.empty()) 354 if (message.empty())
355 message = kFetchScriptError; 355 message = kFetchScriptError;
356 } 356 }
357
358 if (status == SERVICE_WORKER_ERROR_TIMEOUT)
359 message = "Timed out while trying to start the Service Worker.";
360
357 Complete(status, message); 361 Complete(status, message);
358 } 362 }
359 363
360 // This function corresponds to the spec's [[Install]] algorithm. 364 // This function corresponds to the spec's [[Install]] algorithm.
361 void ServiceWorkerRegisterJob::InstallAndContinue() { 365 void ServiceWorkerRegisterJob::InstallAndContinue() {
362 SetPhase(INSTALL); 366 SetPhase(INSTALL);
363 367
364 // "Set registration.installingWorker to worker." 368 // "Set registration.installingWorker to worker."
365 DCHECK(!registration()->installing_version()); 369 DCHECK(!registration()->installing_version());
366 registration()->SetInstallingVersion(new_version()); 370 registration()->SetInstallingVersion(new_version());
(...skipping 15 matching lines...) Expand all
382 386
383 // A subsequent registration job may terminate our installing worker. It can 387 // A subsequent registration job may terminate our installing worker. It can
384 // only do so after we've started the worker and dispatched the install 388 // only do so after we've started the worker and dispatched the install
385 // event, as those are atomic substeps in the [[Install]] algorithm. 389 // event, as those are atomic substeps in the [[Install]] algorithm.
386 if (doom_installing_worker_) 390 if (doom_installing_worker_)
387 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); 391 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED);
388 } 392 }
389 393
390 void ServiceWorkerRegisterJob::OnInstallFinished( 394 void ServiceWorkerRegisterJob::OnInstallFinished(
391 ServiceWorkerStatusCode status) { 395 ServiceWorkerStatusCode status) {
392 // TODO(kinuko,falken): For some error cases (e.g. ServiceWorker is
393 // unexpectedly terminated) we may want to retry sending the event again.
394 if (status != SERVICE_WORKER_OK) { 396 if (status != SERVICE_WORKER_OK) {
395 // "8. If installFailed is true, then:..." 397 // "8. If installFailed is true, then:..."
396 Complete(status); 398 Complete(status);
397 return; 399 return;
398 } 400 }
399 401
400 SetPhase(STORE); 402 SetPhase(STORE);
401 registration()->set_last_update_check(base::Time::Now()); 403 registration()->set_last_update_check(base::Time::Now());
402 context_->storage()->StoreRegistration( 404 context_->storage()->StoreRegistration(
403 registration(), 405 registration(),
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 ServiceWorkerProviderHost* host = it->GetProviderHost(); 557 ServiceWorkerProviderHost* host = it->GetProviderHost();
556 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), 558 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(),
557 host->document_url())) { 559 host->document_url())) {
558 if (host->CanAssociateRegistration(registration)) 560 if (host->CanAssociateRegistration(registration))
559 host->AssociateRegistration(registration); 561 host->AssociateRegistration(registration);
560 } 562 }
561 } 563 }
562 } 564 }
563 565
564 } // namespace content 566 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698