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

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

Issue 2034663002: ServiceWorker: Keep the worker alive until FetchEvent.waitUntil settles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 423
424 void ServiceWorkerRegisterJob::DispatchInstallEvent() { 424 void ServiceWorkerRegisterJob::DispatchInstallEvent() {
425 DCHECK_EQ(ServiceWorkerVersion::INSTALLING, new_version()->status()) 425 DCHECK_EQ(ServiceWorkerVersion::INSTALLING, new_version()->status())
426 << new_version()->status(); 426 << new_version()->status();
427 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, new_version()->running_status()) 427 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, new_version()->running_status())
428 << "Worker stopped too soon after it was started."; 428 << "Worker stopped too soon after it was started.";
429 int request_id = new_version()->StartRequest( 429 int request_id = new_version()->StartRequest(
430 ServiceWorkerMetrics::EventType::INSTALL, 430 ServiceWorkerMetrics::EventType::INSTALL,
431 base::Bind(&ServiceWorkerRegisterJob::OnInstallFailed, 431 base::Bind(&ServiceWorkerRegisterJob::OnInstallFailed,
432 weak_factory_.GetWeakPtr())); 432 weak_factory_.GetWeakPtr()));
433 new_version()->DispatchEvent<ServiceWorkerHostMsg_InstallEventFinished>( 433 new_version()
434 request_id, ServiceWorkerMsg_InstallEvent(request_id), 434 ->RegisterRequestCallback<ServiceWorkerHostMsg_InstallEventFinished>(
435 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, 435 request_id, base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished,
436 weak_factory_.GetWeakPtr())); 436 weak_factory_.GetWeakPtr()));
437 new_version()->DispatchEvent({request_id},
438 ServiceWorkerMsg_InstallEvent(request_id));
437 } 439 }
438 440
439 void ServiceWorkerRegisterJob::OnInstallFinished( 441 void ServiceWorkerRegisterJob::OnInstallFinished(
440 int request_id, 442 int request_id,
441 blink::WebServiceWorkerEventResult result, 443 blink::WebServiceWorkerEventResult result,
442 bool has_fetch_handler) { 444 bool has_fetch_handler) {
443 new_version()->FinishRequest( 445 new_version()->FinishRequest(
444 request_id, result == blink::WebServiceWorkerEventResultCompleted); 446 request_id, result == blink::WebServiceWorkerEventResultCompleted);
445 447
446 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 448 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 new_version()->force_bypass_cache_for_scripts() || 639 new_version()->force_bypass_cache_for_scripts() ||
638 registration()->last_update_check().is_null()) { 640 registration()->last_update_check().is_null()) {
639 registration()->set_last_update_check(base::Time::Now()); 641 registration()->set_last_update_check(base::Time::Now());
640 642
641 if (registration()->has_installed_version()) 643 if (registration()->has_installed_version())
642 context_->storage()->UpdateLastUpdateCheckTime(registration()); 644 context_->storage()->UpdateLastUpdateCheckTime(registration());
643 } 645 }
644 } 646 }
645 647
646 } // namespace content 648 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698