Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: webkit/appcache/appcache_request_handler.cc

Issue 8949001: Fix some loose ends around recently introduced AppCache INTERCEPT namespaces (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_policy.h" 10 #include "webkit/appcache/appcache_policy.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return NULL; 98 return NULL;
99 99
100 DCHECK(!job_); // our jobs never generate redirects 100 DCHECK(!job_); // our jobs never generate redirects
101 101
102 if (found_fallback_entry_.has_response_id()) { 102 if (found_fallback_entry_.has_response_id()) {
103 // 6.9.6, step 4: If this results in a redirect to another origin, 103 // 6.9.6, step 4: If this results in a redirect to another origin,
104 // get the resource of the fallback entry. 104 // get the resource of the fallback entry.
105 job_ = new AppCacheURLRequestJob(request, storage()); 105 job_ = new AppCacheURLRequestJob(request, storage());
106 DeliverAppCachedResponse( 106 DeliverAppCachedResponse(
107 found_fallback_entry_, found_cache_id_, found_group_id_, 107 found_fallback_entry_, found_cache_id_, found_group_id_,
108 found_manifest_url_, true, found_fallback_url_); 108 found_manifest_url_, true, found_namespace_entry_url_);
109 } else if (!found_network_namespace_) { 109 } else if (!found_network_namespace_) {
110 // 6.9.6, step 6: Fail the resource load. 110 // 6.9.6, step 6: Fail the resource load.
111 job_ = new AppCacheURLRequestJob(request, storage()); 111 job_ = new AppCacheURLRequestJob(request, storage());
112 DeliverErrorResponse(); 112 DeliverErrorResponse();
113 } else { 113 } else {
114 // 6.9.6 step 3 and 5: Fetch the resource normally. 114 // 6.9.6 step 3 and 5: Fetch the resource normally.
115 } 115 }
116 116
117 return job_; 117 return job_;
118 } 118 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 request->GetResponseHeaderByName(kFallbackOverrideHeader, &header_value); 150 request->GetResponseHeaderByName(kFallbackOverrideHeader, &header_value);
151 if (header_value == kFallbackOverrideValue) 151 if (header_value == kFallbackOverrideValue)
152 return NULL; 152 return NULL;
153 } 153 }
154 154
155 // 6.9.6, step 4: If this results in a 4xx or 5xx status code 155 // 6.9.6, step 4: If this results in a 4xx or 5xx status code
156 // or there were network errors, get the resource of the fallback entry. 156 // or there were network errors, get the resource of the fallback entry.
157 job_ = new AppCacheURLRequestJob(request, storage()); 157 job_ = new AppCacheURLRequestJob(request, storage());
158 DeliverAppCachedResponse( 158 DeliverAppCachedResponse(
159 found_fallback_entry_, found_cache_id_, found_group_id_, 159 found_fallback_entry_, found_cache_id_, found_group_id_,
160 found_manifest_url_, true, found_fallback_url_); 160 found_manifest_url_, true, found_namespace_entry_url_);
161 return job_; 161 return job_;
162 } 162 }
163 163
164 void AppCacheRequestHandler::OnDestructionImminent(AppCacheHost* host) { 164 void AppCacheRequestHandler::OnDestructionImminent(AppCacheHost* host) {
165 storage()->CancelDelegateCallbacks(this); 165 storage()->CancelDelegateCallbacks(this);
166 host_ = NULL; // no need to RemoveObserver, the host is being deleted 166 host_ = NULL; // no need to RemoveObserver, the host is being deleted
167 167
168 // Since the host is being deleted, we don't have to complete any job 168 // Since the host is being deleted, we don't have to complete any job
169 // that is current running. It's destined for the bit bucket anyway. 169 // that is current running. It's destined for the bit bucket anyway.
170 if (job_) { 170 if (job_) {
171 job_->Kill(); 171 job_->Kill();
172 job_ = NULL; 172 job_ = NULL;
173 } 173 }
174 } 174 }
175 175
176 void AppCacheRequestHandler::DeliverAppCachedResponse( 176 void AppCacheRequestHandler::DeliverAppCachedResponse(
177 const AppCacheEntry& entry, int64 cache_id, int64 group_id, 177 const AppCacheEntry& entry, int64 cache_id, int64 group_id,
178 const GURL& manifest_url, bool is_fallback, const GURL& fallback_url) { 178 const GURL& manifest_url, bool is_fallback,
179 const GURL& namespace_entry_url) {
179 DCHECK(host_ && job_ && job_->is_waiting()); 180 DCHECK(host_ && job_ && job_->is_waiting());
180 DCHECK(entry.has_response_id()); 181 DCHECK(entry.has_response_id());
181 182
182 if (ResourceType::IsFrame(resource_type_) && is_fallback) { 183 if (ResourceType::IsFrame(resource_type_) && !namespace_entry_url.is_empty())
183 DCHECK(!fallback_url.is_empty()); 184 host_->NotifyMainResourceIsNamespaceEntry(namespace_entry_url);
184 host_->NotifyMainResourceFallback(fallback_url);
185 }
186 185
187 job_->DeliverAppCachedResponse(manifest_url, group_id, cache_id, 186 job_->DeliverAppCachedResponse(manifest_url, group_id, cache_id,
188 entry, is_fallback); 187 entry, is_fallback);
189 } 188 }
190 189
191 void AppCacheRequestHandler::DeliverErrorResponse() { 190 void AppCacheRequestHandler::DeliverErrorResponse() {
192 DCHECK(job_ && job_->is_waiting()); 191 DCHECK(job_ && job_->is_waiting());
193 job_->DeliverErrorResponse(); 192 job_->DeliverErrorResponse();
194 } 193 }
195 194
(...skipping 16 matching lines...) Expand all
212 211
213 // We may have to wait for our storage query to complete, but 212 // We may have to wait for our storage query to complete, but
214 // this query can also complete syncrhonously. 213 // this query can also complete syncrhonously.
215 job_ = new AppCacheURLRequestJob(request, storage()); 214 job_ = new AppCacheURLRequestJob(request, storage());
216 storage()->FindResponseForMainRequest( 215 storage()->FindResponseForMainRequest(
217 request->url(), preferred_manifest_url, this); 216 request->url(), preferred_manifest_url, this);
218 } 217 }
219 218
220 void AppCacheRequestHandler::OnMainResponseFound( 219 void AppCacheRequestHandler::OnMainResponseFound(
221 const GURL& url, const AppCacheEntry& entry, 220 const GURL& url, const AppCacheEntry& entry,
222 const GURL& fallback_url, const AppCacheEntry& fallback_entry, 221 const GURL& namespace_entry_url, const AppCacheEntry& fallback_entry,
223 int64 cache_id, int64 group_id, const GURL& manifest_url) { 222 int64 cache_id, int64 group_id, const GURL& manifest_url) {
224 DCHECK(job_); 223 DCHECK(job_);
225 DCHECK(host_); 224 DCHECK(host_);
226 DCHECK(is_main_resource()); 225 DCHECK(is_main_resource());
227 DCHECK(!entry.IsForeign()); 226 DCHECK(!entry.IsForeign());
228 DCHECK(!fallback_entry.IsForeign()); 227 DCHECK(!fallback_entry.IsForeign());
229 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); 228 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id()));
230 229
231 if (!job_) 230 if (!job_)
232 return; 231 return;
(...skipping 18 matching lines...) Expand all
251 // for two reasons, firstly to preload the cache into the working set 250 // for two reasons, firstly to preload the cache into the working set
252 // in advance of subresource loads happening, secondly to prevent the 251 // in advance of subresource loads happening, secondly to prevent the
253 // AppCache from falling out of the working set on frame navigations. 252 // AppCache from falling out of the working set on frame navigations.
254 host_->LoadMainResourceCache(cache_id); 253 host_->LoadMainResourceCache(cache_id);
255 host_->set_preferred_manifest_url(manifest_url); 254 host_->set_preferred_manifest_url(manifest_url);
256 } 255 }
257 256
258 // 6.11.1 Navigating across documents, steps 10 and 14. 257 // 6.11.1 Navigating across documents, steps 10 and 14.
259 258
260 found_entry_ = entry; 259 found_entry_ = entry;
261 found_fallback_url_ = fallback_url; 260 found_namespace_entry_url_ = namespace_entry_url;
262 found_fallback_entry_ = fallback_entry; 261 found_fallback_entry_ = fallback_entry;
263 found_cache_id_ = cache_id; 262 found_cache_id_ = cache_id;
264 found_group_id_ = group_id; 263 found_group_id_ = group_id;
265 found_manifest_url_ = manifest_url; 264 found_manifest_url_ = manifest_url;
266 found_network_namespace_ = false; // not applicable to main requests 265 found_network_namespace_ = false; // not applicable to main requests
267 266
268 if (found_entry_.has_response_id()) { 267 if (found_entry_.has_response_id()) {
268 DCHECK(!found_fallback_entry_.has_response_id());
269 DeliverAppCachedResponse( 269 DeliverAppCachedResponse(
270 found_entry_, found_cache_id_, found_group_id_, found_manifest_url_, 270 found_entry_, found_cache_id_, found_group_id_, found_manifest_url_,
271 false, GURL()); 271 false, found_namespace_entry_url_);
272 } else { 272 } else {
273 DeliverNetworkResponse(); 273 DeliverNetworkResponse();
274 } 274 }
275 } 275 }
276 276
277 // Sub-resource handling ---------------------------------------------- 277 // Sub-resource handling ----------------------------------------------
278 278
279 void AppCacheRequestHandler::MaybeLoadSubResource( 279 void AppCacheRequestHandler::MaybeLoadSubResource(
280 net::URLRequest* request) { 280 net::URLRequest* request) {
281 DCHECK(!job_); 281 DCHECK(!job_);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 if (!host_->associated_cache() || 359 if (!host_->associated_cache() ||
360 !host_->associated_cache()->is_complete()) { 360 !host_->associated_cache()->is_complete()) {
361 DeliverNetworkResponse(); 361 DeliverNetworkResponse();
362 return; 362 return;
363 } 363 }
364 364
365 ContinueMaybeLoadSubResource(); 365 ContinueMaybeLoadSubResource();
366 } 366 }
367 367
368 } // namespace appcache 368 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698