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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 int64 response_id = context_->storage()->NewResourceId(); | 63 int64 response_id = context_->storage()->NewResourceId(); |
64 if (response_id == kInvalidServiceWorkerResponseId) | 64 if (response_id == kInvalidServiceWorkerResponseId) |
65 return NULL; | 65 return NULL; |
66 | 66 |
67 // Bypass the browser cache for initial installs and update | 67 // Bypass the browser cache for initial installs and update |
68 // checks after 24 hours have passed. | 68 // checks after 24 hours have passed. |
69 int extra_load_flags = 0; | 69 int extra_load_flags = 0; |
70 base::TimeDelta time_since_last_check = | 70 base::TimeDelta time_since_last_check = |
71 base::Time::Now() - registration->last_update_check(); | 71 base::Time::Now() - registration->last_update_check(); |
72 if (time_since_last_check > base::TimeDelta::FromHours(24) || | 72 if (time_since_last_check > base::TimeDelta::FromHours( |
| 73 kServiceWorkerScriptMaxCacheAgeInHours) || |
73 version_->force_bypass_cache_for_scripts()) { | 74 version_->force_bypass_cache_for_scripts()) { |
74 extra_load_flags = net::LOAD_BYPASS_CACHE; | 75 extra_load_flags = net::LOAD_BYPASS_CACHE; |
75 } | 76 } |
76 | 77 |
77 ServiceWorkerVersion* stored_version = registration->waiting_version() | 78 ServiceWorkerVersion* stored_version = registration->waiting_version() |
78 ? registration->waiting_version() | 79 ? registration->waiting_version() |
79 : registration->active_version(); | 80 : registration->active_version(); |
80 int64 incumbent_response_id = kInvalidServiceWorkerResourceId; | 81 int64 incumbent_response_id = kInvalidServiceWorkerResourceId; |
81 if (stored_version && stored_version->script_url() == request->url()) { | 82 if (stored_version && stored_version->script_url() == request->url()) { |
82 incumbent_response_id = | 83 incumbent_response_id = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const GURL& url, int64* response_id_out) { | 122 const GURL& url, int64* response_id_out) { |
122 // We don't read from the script cache until the version is INSTALLED. | 123 // We don't read from the script cache until the version is INSTALLED. |
123 if (version_->status() == ServiceWorkerVersion::NEW || | 124 if (version_->status() == ServiceWorkerVersion::NEW || |
124 version_->status() == ServiceWorkerVersion::INSTALLING) | 125 version_->status() == ServiceWorkerVersion::INSTALLING) |
125 return false; | 126 return false; |
126 *response_id_out = version_->script_cache_map()->LookupResourceId(url); | 127 *response_id_out = version_->script_cache_map()->LookupResourceId(url); |
127 return *response_id_out != kInvalidServiceWorkerResponseId; | 128 return *response_id_out != kInvalidServiceWorkerResponseId; |
128 } | 129 } |
129 | 130 |
130 } // namespace content | 131 } // namespace content |
OLD | NEW |