OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/appcache/appcache_request_handler.h" | 5 #include "webkit/appcache/appcache_request_handler.h" |
6 | 6 |
7 #include "net/url_request/url_request.h" | 7 #include "net/url_request/url_request.h" |
8 #include "net/url_request/url_request_job.h" | 8 #include "net/url_request/url_request_job.h" |
9 #include "webkit/appcache/appcache.h" | 9 #include "webkit/appcache/appcache.h" |
10 #include "webkit/appcache/appcache_url_request_job.h" | 10 #include "webkit/appcache/appcache_url_request_job.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 void AppCacheRequestHandler::DeliverNetworkResponse() { | 182 void AppCacheRequestHandler::DeliverNetworkResponse() { |
183 DCHECK(job_ && job_->is_waiting()); | 183 DCHECK(job_ && job_->is_waiting()); |
184 job_->DeliverNetworkResponse(); | 184 job_->DeliverNetworkResponse(); |
185 } | 185 } |
186 | 186 |
187 // Main-resource handling ---------------------------------------------- | 187 // Main-resource handling ---------------------------------------------- |
188 | 188 |
189 void AppCacheRequestHandler::MaybeLoadMainResource(net::URLRequest* request) { | 189 void AppCacheRequestHandler::MaybeLoadMainResource(net::URLRequest* request) { |
190 DCHECK(!job_); | 190 DCHECK(!job_); |
| 191 DCHECK(host_); |
| 192 |
| 193 const AppCacheHost* spawning_host = |
| 194 ResourceType::IsSharedWorker(resource_type_) ? |
| 195 host_ : host_->GetSpawningHost(); |
| 196 GURL preferred_manifest_url = spawning_host ? |
| 197 spawning_host->preferred_manifest_url() : GURL(); |
191 | 198 |
192 // We may have to wait for our storage query to complete, but | 199 // We may have to wait for our storage query to complete, but |
193 // this query can also complete syncrhonously. | 200 // this query can also complete syncrhonously. |
194 job_ = new AppCacheURLRequestJob(request, storage()); | 201 job_ = new AppCacheURLRequestJob(request, storage()); |
195 storage()->FindResponseForMainRequest(request->url(), this); | 202 storage()->FindResponseForMainRequest( |
| 203 request->url(), preferred_manifest_url, this); |
196 } | 204 } |
197 | 205 |
198 void AppCacheRequestHandler::OnMainResponseFound( | 206 void AppCacheRequestHandler::OnMainResponseFound( |
199 const GURL& url, const AppCacheEntry& entry, | 207 const GURL& url, const AppCacheEntry& entry, |
200 const GURL& fallback_url, const AppCacheEntry& fallback_entry, | 208 const GURL& fallback_url, const AppCacheEntry& fallback_entry, |
201 int64 cache_id, const GURL& manifest_url, | 209 int64 cache_id, const GURL& manifest_url, |
202 bool was_blocked_by_policy) { | 210 bool was_blocked_by_policy) { |
203 DCHECK(host_); | 211 DCHECK(host_); |
204 DCHECK(is_main_resource()); | 212 DCHECK(is_main_resource()); |
205 DCHECK(!entry.IsForeign()); | 213 DCHECK(!entry.IsForeign()); |
206 DCHECK(!fallback_entry.IsForeign()); | 214 DCHECK(!fallback_entry.IsForeign()); |
207 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); | 215 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); |
208 | 216 |
209 if (ResourceType::IsFrame(resource_type_)) { | 217 if (ResourceType::IsFrame(resource_type_)) { |
210 if (was_blocked_by_policy) | 218 if (was_blocked_by_policy) |
211 host_->NotifyMainResourceBlocked(manifest_url); | 219 host_->NotifyMainResourceBlocked(manifest_url); |
212 | 220 |
213 if (cache_id != kNoCacheId) { | 221 if (cache_id != kNoCacheId) { |
214 // AppCacheHost loads and holds a reference to the main resource cache | 222 // AppCacheHost loads and holds a reference to the main resource cache |
215 // for two reasons, firstly to preload the cache into the working set | 223 // for two reasons, firstly to preload the cache into the working set |
216 // in advance of subresource loads happening, secondly to prevent the | 224 // in advance of subresource loads happening, secondly to prevent the |
217 // AppCache from falling out of the working set on frame navigations. | 225 // AppCache from falling out of the working set on frame navigations. |
218 host_->LoadMainResourceCache(cache_id); | 226 host_->LoadMainResourceCache(cache_id); |
| 227 host_->set_preferred_manifest_url(manifest_url); |
219 } | 228 } |
220 } else { | 229 } else { |
221 DCHECK(ResourceType::IsSharedWorker(resource_type_)); | 230 DCHECK(ResourceType::IsSharedWorker(resource_type_)); |
222 if (was_blocked_by_policy) | 231 if (was_blocked_by_policy) |
223 host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); | 232 host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); |
224 } | 233 } |
225 | 234 |
226 // 6.11.1 Navigating across documents, steps 10 and 14. | 235 // 6.11.1 Navigating across documents, steps 10 and 14. |
227 | 236 |
228 found_entry_ = entry; | 237 found_entry_ = entry; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 if (!host_->associated_cache() || | 334 if (!host_->associated_cache() || |
326 !host_->associated_cache()->is_complete()) { | 335 !host_->associated_cache()->is_complete()) { |
327 DeliverNetworkResponse(); | 336 DeliverNetworkResponse(); |
328 return; | 337 return; |
329 } | 338 } |
330 | 339 |
331 ContinueMaybeLoadSubResource(); | 340 ContinueMaybeLoadSubResource(); |
332 } | 341 } |
333 | 342 |
334 } // namespace appcache | 343 } // namespace appcache |
OLD | NEW |