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

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

Issue 1187623006: Service Worker: Update stale workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix DCHECK Created 5 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 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/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 return false; 534 return false;
535 } 535 }
536 536
537 void ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete( 537 void ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete(
538 ServiceWorkerStatusCode status, 538 ServiceWorkerStatusCode status,
539 bool are_equal) { 539 bool are_equal) {
540 if (are_equal) { 540 if (are_equal) {
541 // Only bump the last check time when we've bypassed the browser cache. 541 // Only bump the last check time when we've bypassed the browser cache.
542 base::TimeDelta time_since_last_check = 542 base::TimeDelta time_since_last_check =
543 base::Time::Now() - registration()->last_update_check(); 543 base::Time::Now() - registration()->last_update_check();
544 if (time_since_last_check > base::TimeDelta::FromHours(24) || 544 if (time_since_last_check > base::TimeDelta::FromHours(
545 kServiceWorkerScriptMaxCacheAgeInHours) ||
545 new_version()->force_bypass_cache_for_scripts()) { 546 new_version()->force_bypass_cache_for_scripts()) {
546 registration()->set_last_update_check(base::Time::Now()); 547 registration()->set_last_update_check(base::Time::Now());
547 context_->storage()->UpdateLastUpdateCheckTime(registration()); 548 context_->storage()->UpdateLastUpdateCheckTime(registration());
548 } 549 }
549 550
550 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); 551 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration());
551 Complete(SERVICE_WORKER_ERROR_EXISTS); 552 Complete(SERVICE_WORKER_ERROR_EXISTS);
552 return; 553 return;
553 } 554 }
554 555
(...skipping 12 matching lines...) Expand all
567 if (host->IsHostToRunningServiceWorker()) 568 if (host->IsHostToRunningServiceWorker())
568 continue; 569 continue;
569 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), 570 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(),
570 host->document_url())) 571 host->document_url()))
571 continue; 572 continue;
572 host->AddMatchingRegistration(registration); 573 host->AddMatchingRegistration(registration);
573 } 574 }
574 } 575 }
575 576
576 } // namespace content 577 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698