Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_context_request_handler. h" | 5 #include "content/browser/service_worker/service_worker_context_request_handler. h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "content/browser/service_worker/service_worker_context_core.h" | 8 #include "content/browser/service_worker/service_worker_context_core.h" |
| 9 #include "content/browser/service_worker/service_worker_provider_host.h" | 9 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 10 #include "content/browser/service_worker/service_worker_read_from_cache_job.h" | 10 #include "content/browser/service_worker/service_worker_read_from_cache_job.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 if (resource_id == kInvalidServiceWorkerResourceId) { | 202 if (resource_id == kInvalidServiceWorkerResourceId) { |
| 203 *out_status = CreateJobStatus::ERROR_OUT_OF_RESOURCE_IDS; | 203 *out_status = CreateJobStatus::ERROR_OUT_OF_RESOURCE_IDS; |
| 204 return nullptr; | 204 return nullptr; |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Bypass the browser cache for initial installs and update checks after 24 | 207 // Bypass the browser cache for initial installs and update checks after 24 |
| 208 // hours have passed. | 208 // hours have passed. |
| 209 int extra_load_flags = 0; | 209 int extra_load_flags = 0; |
| 210 base::TimeDelta time_since_last_check = | 210 base::TimeDelta time_since_last_check = |
| 211 base::Time::Now() - registration->last_update_check(); | 211 base::Time::Now() - registration->last_update_check(); |
| 212 if (time_since_last_check > kServiceWorkerScriptMaxCacheAge || | 212 bool no_update_via_cache = |
|
nhiroki
2017/06/21 15:04:59
|no_update_via_cache| sounds a bit confusing. How
yuryu
2017/07/20 10:15:12
Done.
| |
| 213 (is_main_script && registration->update_via_cache() != | |
| 214 blink::WebServiceWorkerUpdateViaCache::kAll) || | |
| 215 (!is_main_script && registration->update_via_cache() == | |
|
nhiroki
2017/06/21 15:04:59
|!is_main_script| would be unnecessary.
yuryu
2017/07/20 10:15:12
I intended to reflect the spec, where algorithms f
| |
| 216 blink::WebServiceWorkerUpdateViaCache::kNone); | |
| 217 if (no_update_via_cache || | |
| 218 time_since_last_check > kServiceWorkerScriptMaxCacheAge || | |
| 213 version_->force_bypass_cache_for_scripts()) { | 219 version_->force_bypass_cache_for_scripts()) { |
| 214 extra_load_flags = net::LOAD_BYPASS_CACHE; | 220 extra_load_flags = net::LOAD_BYPASS_CACHE; |
| 215 } | 221 } |
| 216 | 222 |
| 217 ServiceWorkerVersion* stored_version = registration->waiting_version() | 223 ServiceWorkerVersion* stored_version = registration->waiting_version() |
| 218 ? registration->waiting_version() | 224 ? registration->waiting_version() |
| 219 : registration->active_version(); | 225 : registration->active_version(); |
| 220 int64_t incumbent_resource_id = kInvalidServiceWorkerResourceId; | 226 int64_t incumbent_resource_id = kInvalidServiceWorkerResourceId; |
| 221 if (is_main_script) { | 227 if (is_main_script) { |
| 222 if (stored_version && stored_version->script_url() == request->url()) { | 228 if (stored_version && stored_version->script_url() == request->url()) { |
| 223 incumbent_resource_id = | 229 incumbent_resource_id = |
| 224 stored_version->script_cache_map()->LookupResourceId(request->url()); | 230 stored_version->script_cache_map()->LookupResourceId(request->url()); |
| 225 } | 231 } |
| 226 version_->embedded_worker()->OnURLJobCreatedForMainScript(); | 232 version_->embedded_worker()->OnURLJobCreatedForMainScript(); |
| 227 } | 233 } |
| 228 *out_status = incumbent_resource_id == kInvalidServiceWorkerResourceId | 234 *out_status = incumbent_resource_id == kInvalidServiceWorkerResourceId |
| 229 ? CreateJobStatus::WRITE_JOB | 235 ? CreateJobStatus::WRITE_JOB |
| 230 : CreateJobStatus::WRITE_JOB_WITH_INCUMBENT; | 236 : CreateJobStatus::WRITE_JOB_WITH_INCUMBENT; |
| 231 return new ServiceWorkerWriteToCacheJob( | 237 return new ServiceWorkerWriteToCacheJob( |
| 232 request, network_delegate, resource_type_, context_, version_.get(), | 238 request, network_delegate, resource_type_, context_, version_.get(), |
| 233 extra_load_flags, resource_id, incumbent_resource_id); | 239 extra_load_flags, resource_id, incumbent_resource_id); |
| 234 } | 240 } |
| 235 | 241 |
| 236 } // namespace content | 242 } // namespace content |
| OLD | NEW |