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

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

Issue 10829356: Make sure that AppCache tests subresource URLrequests against NETWORK whitelist (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « webkit/appcache/appcache_request_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "webkit/appcache/appcache_url_request_job.h" 11 #include "webkit/appcache/appcache_url_request_job.h"
12 12
13 namespace appcache { 13 namespace appcache {
14 14
15 AppCacheRequestHandler::AppCacheRequestHandler( 15 AppCacheRequestHandler::AppCacheRequestHandler(
16 AppCacheHost* host, ResourceType::Type resource_type) 16 AppCacheHost* host, ResourceType::Type resource_type)
17 : host_(host), resource_type_(resource_type), 17 : host_(host), resource_type_(resource_type),
18 is_waiting_for_cache_selection_(false), found_group_id_(0), 18 is_waiting_for_cache_selection_(false), found_group_id_(0),
19 found_cache_id_(0), found_network_namespace_(false), 19 found_cache_id_(0), found_network_namespace_(false),
20 cache_entry_not_found_(false) { 20 request_response_found_(false), cache_entry_not_found_(false) {
21 DCHECK(host_); 21 DCHECK(host_);
22 host_->AddObserver(this); 22 host_->AddObserver(this);
23 } 23 }
24 24
25 AppCacheRequestHandler::~AppCacheRequestHandler() { 25 AppCacheRequestHandler::~AppCacheRequestHandler() {
26 if (host_) { 26 if (host_) {
27 storage()->CancelDelegateCallbacks(this); 27 storage()->CancelDelegateCallbacks(this);
28 host_->RemoveObserver(this); 28 host_->RemoveObserver(this);
29 } 29 }
30 } 30 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return NULL; 64 return NULL;
65 } 65 }
66 66
67 // Clear out our 'found' fields since we're starting a request for a 67 // Clear out our 'found' fields since we're starting a request for a
68 // new resource, any values in those fields are no longer valid. 68 // new resource, any values in those fields are no longer valid.
69 found_entry_ = AppCacheEntry(); 69 found_entry_ = AppCacheEntry();
70 found_fallback_entry_ = AppCacheEntry(); 70 found_fallback_entry_ = AppCacheEntry();
71 found_cache_id_ = kNoCacheId; 71 found_cache_id_ = kNoCacheId;
72 found_manifest_url_ = GURL(); 72 found_manifest_url_ = GURL();
73 found_network_namespace_ = false; 73 found_network_namespace_ = false;
74 request_response_found_ = false;
74 75
75 if (is_main_resource()) 76 if (is_main_resource())
76 MaybeLoadMainResource(request); 77 MaybeLoadMainResource(request);
77 else 78 else
78 MaybeLoadSubResource(request); 79 MaybeLoadSubResource(request);
79 80
80 // If its been setup to deliver a network response, we can just delete 81 // If its been setup to deliver a network response, we can just delete
81 // it now and return NULL instead to achieve that since it couldn't 82 // it now and return NULL instead to achieve that since it couldn't
82 // have been started yet. 83 // have been started yet.
83 if (job_ && job_->is_delivering_network_response()) { 84 if (job_ && job_->is_delivering_network_response()) {
84 DCHECK(!job_->has_been_started()); 85 DCHECK(!job_->has_been_started());
85 job_ = NULL; 86 job_ = NULL;
86 } 87 }
87 88
88 return job_; 89 return job_;
89 } 90 }
90 91
91 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect( 92 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect(
92 net::URLRequest* request, const GURL& location) { 93 net::URLRequest* request, const GURL& location) {
93 if (!host_ || !IsSchemeAndMethodSupported(request) || cache_entry_not_found_) 94 if (!host_ || !IsSchemeAndMethodSupported(request) || cache_entry_not_found_)
94 return NULL; 95 return NULL;
95 if (is_main_resource()) 96 if (is_main_resource())
96 return NULL; 97 return NULL;
97 if (request->url().GetOrigin() == location.GetOrigin()) 98 if (request->url().GetOrigin() == location.GetOrigin())
98 return NULL; 99 return NULL;
99 100
100 DCHECK(!job_); // our jobs never generate redirects 101 DCHECK(!job_); // our jobs never generate redirects
101 102
michaeln 2012/08/17 00:50:43 I think there's an additional condition that has t
vabr (Chromium) 2012/08/17 16:22:35 This should now be addressed by the call to MaybeL
103 if (!request_response_found_) {
104 storage()->FindResponseForSubRequest(
105 host_->associated_cache(), request->url(),
106 &found_entry_, &found_fallback_entry_, &found_network_namespace_);
michaeln 2012/08/17 00:50:43 What should we do if found_entry_.has_response_id(
vabr (Chromium) 2012/08/17 16:22:35 Here I realised that I should use original_url(),
107 request_response_found_ = true;
108 }
102 if (found_fallback_entry_.has_response_id()) { 109 if (found_fallback_entry_.has_response_id()) {
michaeln 2012/08/17 00:50:43 As coded we'll will load an appcached fallback res
vabr (Chromium) 2012/08/17 16:22:35 Through the use of MaybeLoadResource within MaybeL
103 // 6.9.6, step 4: If this results in a redirect to another origin, 110 // 6.9.6, step 4: If this results in a redirect to another origin,
104 // get the resource of the fallback entry. 111 // get the resource of the fallback entry.
105 job_ = new AppCacheURLRequestJob(request, storage()); 112 job_ = new AppCacheURLRequestJob(request, storage());
106 DeliverAppCachedResponse( 113 DeliverAppCachedResponse(
107 found_fallback_entry_, found_cache_id_, found_group_id_, 114 found_fallback_entry_, found_cache_id_, found_group_id_,
108 found_manifest_url_, true, found_namespace_entry_url_); 115 found_manifest_url_, true, found_namespace_entry_url_);
109 } else if (!found_network_namespace_) { 116 } else if (!found_network_namespace_) {
110 // 6.9.6, step 6: Fail the resource load. 117 // 6.9.6, step 6: Fail the resource load.
111 job_ = new AppCacheURLRequestJob(request, storage()); 118 job_ = new AppCacheURLRequestJob(request, storage());
112 DeliverErrorResponse(); 119 DeliverErrorResponse();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // equivalent ... then fetch the resource normally. 310 // equivalent ... then fetch the resource normally.
304 DCHECK(job_); 311 DCHECK(job_);
305 DCHECK(host_->associated_cache() && 312 DCHECK(host_->associated_cache() &&
306 host_->associated_cache()->is_complete()); 313 host_->associated_cache()->is_complete());
307 314
308 const GURL& url = job_->request()->url(); 315 const GURL& url = job_->request()->url();
309 AppCache* cache = host_->associated_cache(); 316 AppCache* cache = host_->associated_cache();
310 storage()->FindResponseForSubRequest( 317 storage()->FindResponseForSubRequest(
311 host_->associated_cache(), url, 318 host_->associated_cache(), url,
312 &found_entry_, &found_fallback_entry_, &found_network_namespace_); 319 &found_entry_, &found_fallback_entry_, &found_network_namespace_);
320 request_response_found_ = true;
313 321
314 if (found_entry_.has_response_id()) { 322 if (found_entry_.has_response_id()) {
315 // Step 2: If there's an entry, get it instead. 323 // Step 2: If there's an entry, get it instead.
316 DCHECK(!found_network_namespace_ && 324 DCHECK(!found_network_namespace_ &&
317 !found_fallback_entry_.has_response_id()); 325 !found_fallback_entry_.has_response_id());
318 found_cache_id_ = cache->cache_id(); 326 found_cache_id_ = cache->cache_id();
319 found_group_id_ = cache->owning_group()->group_id(); 327 found_group_id_ = cache->owning_group()->group_id();
320 found_manifest_url_ = cache->owning_group()->manifest_url(); 328 found_manifest_url_ = cache->owning_group()->manifest_url();
321 DeliverAppCachedResponse( 329 DeliverAppCachedResponse(
322 found_entry_, found_cache_id_, found_group_id_, found_manifest_url_, 330 found_entry_, found_cache_id_, found_group_id_, found_manifest_url_,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 if (!host_->associated_cache() || 367 if (!host_->associated_cache() ||
360 !host_->associated_cache()->is_complete()) { 368 !host_->associated_cache()->is_complete()) {
361 DeliverNetworkResponse(); 369 DeliverNetworkResponse();
362 return; 370 return;
363 } 371 }
364 372
365 ContinueMaybeLoadSubResource(); 373 ContinueMaybeLoadSubResource();
366 } 374 }
367 375
368 } // namespace appcache 376 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_request_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698