OLD | NEW |
---|---|
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 if (status == SERVICE_WORKER_OK) { | 340 if (status == SERVICE_WORKER_OK) { |
341 InstallAndContinue(); | 341 InstallAndContinue(); |
342 return; | 342 return; |
343 } | 343 } |
344 | 344 |
345 // The updated worker is identical to the incumbent. | 345 // The updated worker is identical to the incumbent. |
346 if (status == SERVICE_WORKER_ERROR_EXISTS) { | 346 if (status == SERVICE_WORKER_ERROR_EXISTS) { |
347 // Only bump the last check time when we've bypassed the browser cache. | 347 // Only bump the last check time when we've bypassed the browser cache. |
348 base::TimeDelta time_since_last_check = | 348 base::TimeDelta time_since_last_check = |
349 base::Time::Now() - registration()->last_update_check(); | 349 base::Time::Now() - registration()->last_update_check(); |
350 if (time_since_last_check > base::TimeDelta::FromHours( | 350 if (time_since_last_check > new_version()->max_age() || |
nhiroki
2015/08/19 06:59:01
We could use EmbeddedWorkerInstance::network_acces
jungkees
2015/08/20 01:52:56
I got it. Thanks for the point.
| |
351 kServiceWorkerScriptMaxCacheAgeInHours) || | |
352 new_version()->force_bypass_cache_for_scripts()) { | 351 new_version()->force_bypass_cache_for_scripts()) { |
353 registration()->set_last_update_check(base::Time::Now()); | 352 registration()->set_last_update_check(base::Time::Now()); |
354 context_->storage()->UpdateLastUpdateCheckTime(registration()); | 353 context_->storage()->UpdateLastUpdateCheckTime(registration()); |
355 } | 354 } |
356 | 355 |
357 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); | 356 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); |
358 Complete(status, "The updated worker is identical to the incumbent."); | 357 Complete(status, "The updated worker is identical to the incumbent."); |
359 return; | 358 return; |
360 } | 359 } |
361 | 360 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 if (host->IsHostToRunningServiceWorker()) | 531 if (host->IsHostToRunningServiceWorker()) |
533 continue; | 532 continue; |
534 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), | 533 if (!ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
535 host->document_url())) | 534 host->document_url())) |
536 continue; | 535 continue; |
537 host->AddMatchingRegistration(registration); | 536 host->AddMatchingRegistration(registration); |
538 } | 537 } |
539 } | 538 } |
540 | 539 |
541 } // namespace content | 540 } // namespace content |
OLD | NEW |