| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 version_->embedded_worker()->OnURLJobCreatedForMainScript(); | 96 version_->embedded_worker()->OnURLJobCreatedForMainScript(); |
| 97 return new ServiceWorkerReadFromCacheJob(request, network_delegate, | 97 return new ServiceWorkerReadFromCacheJob(request, network_delegate, |
| 98 resource_type_, context_, version_, | 98 resource_type_, context_, version_, |
| 99 resource_id); | 99 resource_id); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // NULL means use the network. | 102 // NULL means use the network. |
| 103 return NULL; | 103 return NULL; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ServiceWorkerContextRequestHandler::GetExtraResponseInfo( | |
| 107 ResourceResponseInfo* response_info) const { | |
| 108 response_info->was_fetched_via_service_worker = false; | |
| 109 response_info->was_fallback_required_by_service_worker = false; | |
| 110 response_info->original_url_via_service_worker = GURL(); | |
| 111 response_info->response_type_via_service_worker = | |
| 112 blink::WebServiceWorkerResponseTypeDefault; | |
| 113 } | |
| 114 | |
| 115 bool ServiceWorkerContextRequestHandler::ShouldAddToScriptCache( | 106 bool ServiceWorkerContextRequestHandler::ShouldAddToScriptCache( |
| 116 const GURL& url) { | 107 const GURL& url) { |
| 117 // We only write imports that occur during the initial eval. | 108 // We only write imports that occur during the initial eval. |
| 118 if (version_->status() != ServiceWorkerVersion::NEW && | 109 if (version_->status() != ServiceWorkerVersion::NEW && |
| 119 version_->status() != ServiceWorkerVersion::INSTALLING) { | 110 version_->status() != ServiceWorkerVersion::INSTALLING) { |
| 120 return false; | 111 return false; |
| 121 } | 112 } |
| 122 return version_->script_cache_map()->LookupResourceId(url) == | 113 return version_->script_cache_map()->LookupResourceId(url) == |
| 123 kInvalidServiceWorkerResourceId; | 114 kInvalidServiceWorkerResourceId; |
| 124 } | 115 } |
| 125 | 116 |
| 126 bool ServiceWorkerContextRequestHandler::ShouldReadFromScriptCache( | 117 bool ServiceWorkerContextRequestHandler::ShouldReadFromScriptCache( |
| 127 const GURL& url, | 118 const GURL& url, |
| 128 int64_t* resource_id_out) { | 119 int64_t* resource_id_out) { |
| 129 // We don't read from the script cache until the version is INSTALLED. | 120 // We don't read from the script cache until the version is INSTALLED. |
| 130 if (version_->status() == ServiceWorkerVersion::NEW || | 121 if (version_->status() == ServiceWorkerVersion::NEW || |
| 131 version_->status() == ServiceWorkerVersion::INSTALLING) | 122 version_->status() == ServiceWorkerVersion::INSTALLING) |
| 132 return false; | 123 return false; |
| 133 *resource_id_out = version_->script_cache_map()->LookupResourceId(url); | 124 *resource_id_out = version_->script_cache_map()->LookupResourceId(url); |
| 134 return *resource_id_out != kInvalidServiceWorkerResourceId; | 125 return *resource_id_out != kInvalidServiceWorkerResourceId; |
| 135 } | 126 } |
| 136 | 127 |
| 137 } // namespace content | 128 } // namespace content |
| OLD | NEW |