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 AppCacheHost* spawning_host = ResourceType::IsSharedWorker(resource_type_) ? | |
jennb
2011/04/12 00:07:56
How does SharedWorker affect which host to use as
michaeln
2011/04/14 23:41:23
In the current system, the main resource of a shar
| |
194 host_ : host_->GetSpawningHost(); | |
195 GURL preferred_manifest_url = spawning_host ? | |
196 spawning_host->preferred_manifest_url() : GURL(); | |
191 | 197 |
192 // We may have to wait for our storage query to complete, but | 198 // We may have to wait for our storage query to complete, but |
193 // this query can also complete syncrhonously. | 199 // this query can also complete syncrhonously. |
194 job_ = new AppCacheURLRequestJob(request, storage()); | 200 job_ = new AppCacheURLRequestJob(request, storage()); |
195 storage()->FindResponseForMainRequest(request->url(), this); | 201 storage()->FindResponseForMainRequest( |
202 request->url(), preferred_manifest_url, this); | |
196 } | 203 } |
197 | 204 |
198 void AppCacheRequestHandler::OnMainResponseFound( | 205 void AppCacheRequestHandler::OnMainResponseFound( |
199 const GURL& url, const AppCacheEntry& entry, | 206 const GURL& url, const AppCacheEntry& entry, |
200 const GURL& fallback_url, const AppCacheEntry& fallback_entry, | 207 const GURL& fallback_url, const AppCacheEntry& fallback_entry, |
201 int64 cache_id, const GURL& manifest_url, | 208 int64 cache_id, const GURL& manifest_url, |
202 bool was_blocked_by_policy) { | 209 bool was_blocked_by_policy) { |
203 DCHECK(host_); | 210 DCHECK(host_); |
204 DCHECK(is_main_resource()); | 211 DCHECK(is_main_resource()); |
205 DCHECK(!entry.IsForeign()); | 212 DCHECK(!entry.IsForeign()); |
206 DCHECK(!fallback_entry.IsForeign()); | 213 DCHECK(!fallback_entry.IsForeign()); |
207 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); | 214 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); |
208 | 215 |
209 if (ResourceType::IsFrame(resource_type_)) { | 216 if (ResourceType::IsFrame(resource_type_)) { |
210 if (was_blocked_by_policy) | 217 if (was_blocked_by_policy) |
211 host_->NotifyMainResourceBlocked(manifest_url); | 218 host_->NotifyMainResourceBlocked(manifest_url); |
212 | 219 |
213 if (cache_id != kNoCacheId) { | 220 if (cache_id != kNoCacheId) { |
214 // AppCacheHost loads and holds a reference to the main resource cache | 221 // AppCacheHost loads and holds a reference to the main resource cache |
215 // for two reasons, firstly to preload the cache into the working set | 222 // for two reasons, firstly to preload the cache into the working set |
216 // in advance of subresource loads happening, secondly to prevent the | 223 // in advance of subresource loads happening, secondly to prevent the |
217 // AppCache from falling out of the working set on frame navigations. | 224 // AppCache from falling out of the working set on frame navigations. |
218 host_->LoadMainResourceCache(cache_id); | 225 host_->LoadMainResourceCache(cache_id); |
226 host_->set_preferred_manifest_url(manifest_url); | |
219 } | 227 } |
220 } else { | 228 } else { |
221 DCHECK(ResourceType::IsSharedWorker(resource_type_)); | 229 DCHECK(ResourceType::IsSharedWorker(resource_type_)); |
222 if (was_blocked_by_policy) | 230 if (was_blocked_by_policy) |
223 host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); | 231 host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); |
224 } | 232 } |
225 | 233 |
226 // 6.11.1 Navigating across documents, steps 10 and 14. | 234 // 6.11.1 Navigating across documents, steps 10 and 14. |
227 | 235 |
228 found_entry_ = entry; | 236 found_entry_ = entry; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 if (!host_->associated_cache() || | 333 if (!host_->associated_cache() || |
326 !host_->associated_cache()->is_complete()) { | 334 !host_->associated_cache()->is_complete()) { |
327 DeliverNetworkResponse(); | 335 DeliverNetworkResponse(); |
328 return; | 336 return; |
329 } | 337 } |
330 | 338 |
331 ContinueMaybeLoadSubResource(); | 339 ContinueMaybeLoadSubResource(); |
332 } | 340 } |
333 | 341 |
334 } // namespace appcache | 342 } // namespace appcache |
OLD | NEW |