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 "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_provider_host.h" | 8 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 9 #include "content/browser/service_worker/service_worker_read_from_cache_job.h" | 9 #include "content/browser/service_worker/service_worker_read_from_cache_job.h" |
| 10 #include "content/browser/service_worker/service_worker_storage.h" | 10 #include "content/browser/service_worker/service_worker_storage.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 int64 response_id = kInvalidServiceWorkerResponseId; | 65 int64 response_id = kInvalidServiceWorkerResponseId; |
| 66 if (ShouldReadFromScriptCache(request->url(), &response_id)) { | 66 if (ShouldReadFromScriptCache(request->url(), &response_id)) { |
| 67 return new ServiceWorkerReadFromCacheJob( | 67 return new ServiceWorkerReadFromCacheJob( |
| 68 request, network_delegate, context_, response_id); | 68 request, network_delegate, context_, response_id); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // NULL means use the network. | 71 // NULL means use the network. |
| 72 return NULL; | 72 return NULL; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ServiceWorkerContextRequestHandler::GetExtraResponseInfo( | |
| 76 bool* was_fetched_via_service_worker, | |
| 77 GURL* original_url_via_service_worker) const { | |
| 78 *was_fetched_via_service_worker = false; | |
|
michaeln
2014/07/17 19:34:20
maybe set both out params instead of trusting that
horo
2014/07/18 04:17:39
Done.
| |
| 79 } | |
| 80 | |
| 75 bool ServiceWorkerContextRequestHandler::ShouldAddToScriptCache( | 81 bool ServiceWorkerContextRequestHandler::ShouldAddToScriptCache( |
| 76 const GURL& url) { | 82 const GURL& url) { |
| 77 // We only write imports that occur during the initial eval. | 83 // We only write imports that occur during the initial eval. |
| 78 if (version_->status() != ServiceWorkerVersion::NEW && | 84 if (version_->status() != ServiceWorkerVersion::NEW && |
| 79 version_->status() != ServiceWorkerVersion::INSTALLING) { | 85 version_->status() != ServiceWorkerVersion::INSTALLING) { |
| 80 return false; | 86 return false; |
| 81 } | 87 } |
| 82 return version_->script_cache_map()->Lookup(url) == | 88 return version_->script_cache_map()->Lookup(url) == |
| 83 kInvalidServiceWorkerResponseId; | 89 kInvalidServiceWorkerResponseId; |
| 84 } | 90 } |
| 85 | 91 |
| 86 bool ServiceWorkerContextRequestHandler::ShouldReadFromScriptCache( | 92 bool ServiceWorkerContextRequestHandler::ShouldReadFromScriptCache( |
| 87 const GURL& url, int64* response_id_out) { | 93 const GURL& url, int64* response_id_out) { |
| 88 // We don't read from the script cache until the version is INSTALLED. | 94 // We don't read from the script cache until the version is INSTALLED. |
| 89 if (version_->status() == ServiceWorkerVersion::NEW || | 95 if (version_->status() == ServiceWorkerVersion::NEW || |
| 90 version_->status() == ServiceWorkerVersion::INSTALLING) | 96 version_->status() == ServiceWorkerVersion::INSTALLING) |
| 91 return false; | 97 return false; |
| 92 *response_id_out = version_->script_cache_map()->Lookup(url); | 98 *response_id_out = version_->script_cache_map()->Lookup(url); |
| 93 return *response_id_out != kInvalidServiceWorkerResponseId; | 99 return *response_id_out != kInvalidServiceWorkerResponseId; |
| 94 } | 100 } |
| 95 | 101 |
| 96 } // namespace content | 102 } // namespace content |
| OLD | NEW |