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

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

Issue 1795863006: service worker: Attribute purpose to start worker attempts for UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch for landing? Created 4 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 set_new_version(new ServiceWorkerVersion(registration(), script_url_, 344 set_new_version(new ServiceWorkerVersion(registration(), script_url_,
345 version_id, context_)); 345 version_id, context_));
346 new_version()->set_force_bypass_cache_for_scripts(force_bypass_cache_); 346 new_version()->set_force_bypass_cache_for_scripts(force_bypass_cache_);
347 if (registration()->has_installed_version() && !skip_script_comparison_) { 347 if (registration()->has_installed_version() && !skip_script_comparison_) {
348 new_version()->set_pause_after_download(true); 348 new_version()->set_pause_after_download(true);
349 new_version()->embedded_worker()->AddListener(this); 349 new_version()->embedded_worker()->AddListener(this);
350 } else { 350 } else {
351 new_version()->set_pause_after_download(false); 351 new_version()->set_pause_after_download(false);
352 } 352 }
353 new_version()->StartWorker( 353 new_version()->StartWorker(
354 ServiceWorkerMetrics::EventType::INSTALL,
354 base::Bind(&ServiceWorkerRegisterJob::OnStartWorkerFinished, 355 base::Bind(&ServiceWorkerRegisterJob::OnStartWorkerFinished,
355 weak_factory_.GetWeakPtr())); 356 weak_factory_.GetWeakPtr()));
356 } 357 }
357 358
358 void ServiceWorkerRegisterJob::OnStartWorkerFinished( 359 void ServiceWorkerRegisterJob::OnStartWorkerFinished(
359 ServiceWorkerStatusCode status) { 360 ServiceWorkerStatusCode status) {
360 // Bump the last update check time only when the register/update job fetched 361 // Bump the last update check time only when the register/update job fetched
361 // the version having bypassed the network cache. We assume that the 362 // the version having bypassed the network cache. We assume that the
362 // BYPASS_CACHE flag evicts an existing cache entry, so even if the install 363 // BYPASS_CACHE flag evicts an existing cache entry, so even if the install
363 // ultimately failed for whatever reason, we know the version in the HTTP 364 // ultimately failed for whatever reason, we know the version in the HTTP
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 new_version()->SetStatus(ServiceWorkerVersion::INSTALLING); 408 new_version()->SetStatus(ServiceWorkerVersion::INSTALLING);
408 409
409 // "Resolve registrationPromise with registration." 410 // "Resolve registrationPromise with registration."
410 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); 411 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration());
411 412
412 // "Fire a simple event named updatefound..." 413 // "Fire a simple event named updatefound..."
413 registration()->NotifyUpdateFound(); 414 registration()->NotifyUpdateFound();
414 415
415 // "Fire an event named install..." 416 // "Fire an event named install..."
416 new_version()->RunAfterStartWorker( 417 new_version()->RunAfterStartWorker(
418 ServiceWorkerMetrics::EventType::INSTALL,
417 base::Bind(&ServiceWorkerRegisterJob::DispatchInstallEvent, 419 base::Bind(&ServiceWorkerRegisterJob::DispatchInstallEvent,
418 weak_factory_.GetWeakPtr()), 420 weak_factory_.GetWeakPtr()),
419 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, 421 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished,
420 weak_factory_.GetWeakPtr())); 422 weak_factory_.GetWeakPtr()));
421 423
422 // A subsequent registration job may terminate our installing worker. It can 424 // A subsequent registration job may terminate our installing worker. It can
423 // only do so after we've started the worker and dispatched the install 425 // only do so after we've started the worker and dispatched the install
424 // event, as those are atomic substeps in the [[Install]] algorithm. 426 // event, as those are atomic substeps in the [[Install]] algorithm.
425 if (doom_installing_worker_) 427 if (doom_installing_worker_)
426 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); 428 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); 592 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration());
591 Complete(SERVICE_WORKER_ERROR_EXISTS, 593 Complete(SERVICE_WORKER_ERROR_EXISTS,
592 "The updated worker is identical to the incumbent."); 594 "The updated worker is identical to the incumbent.");
593 return; 595 return;
594 } 596 }
595 597
596 new_version()->embedded_worker()->ResumeAfterDownload(); 598 new_version()->embedded_worker()->ResumeAfterDownload();
597 } 599 }
598 600
599 } // namespace content 601 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698