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; |
| 79 *original_url_via_service_worker = GURL(); |
| 80 } |
| 81 |
75 bool ServiceWorkerContextRequestHandler::ShouldAddToScriptCache( | 82 bool ServiceWorkerContextRequestHandler::ShouldAddToScriptCache( |
76 const GURL& url) { | 83 const GURL& url) { |
77 // We only write imports that occur during the initial eval. | 84 // We only write imports that occur during the initial eval. |
78 if (version_->status() != ServiceWorkerVersion::NEW && | 85 if (version_->status() != ServiceWorkerVersion::NEW && |
79 version_->status() != ServiceWorkerVersion::INSTALLING) { | 86 version_->status() != ServiceWorkerVersion::INSTALLING) { |
80 return false; | 87 return false; |
81 } | 88 } |
82 return version_->script_cache_map()->Lookup(url) == | 89 return version_->script_cache_map()->Lookup(url) == |
83 kInvalidServiceWorkerResponseId; | 90 kInvalidServiceWorkerResponseId; |
84 } | 91 } |
85 | 92 |
86 bool ServiceWorkerContextRequestHandler::ShouldReadFromScriptCache( | 93 bool ServiceWorkerContextRequestHandler::ShouldReadFromScriptCache( |
87 const GURL& url, int64* response_id_out) { | 94 const GURL& url, int64* response_id_out) { |
88 // We don't read from the script cache until the version is INSTALLED. | 95 // We don't read from the script cache until the version is INSTALLED. |
89 if (version_->status() == ServiceWorkerVersion::NEW || | 96 if (version_->status() == ServiceWorkerVersion::NEW || |
90 version_->status() == ServiceWorkerVersion::INSTALLING) | 97 version_->status() == ServiceWorkerVersion::INSTALLING) |
91 return false; | 98 return false; |
92 *response_id_out = version_->script_cache_map()->Lookup(url); | 99 *response_id_out = version_->script_cache_map()->Lookup(url); |
93 return *response_id_out != kInvalidServiceWorkerResponseId; | 100 return *response_id_out != kInvalidServiceWorkerResponseId; |
94 } | 101 } |
95 | 102 |
96 } // namespace content | 103 } // namespace content |
OLD | NEW |