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

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: TODO added Created 8 years, 3 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 cache_entry_not_found_(false), maybe_load_resource_executed_(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 }
31 31
32 AppCacheStorage* AppCacheRequestHandler::storage() const { 32 AppCacheStorage* AppCacheRequestHandler::storage() const {
33 DCHECK(host_); 33 DCHECK(host_);
34 return host_->service()->storage(); 34 return host_->service()->storage();
35 } 35 }
36 36
37 void AppCacheRequestHandler::GetExtraResponseInfo( 37 void AppCacheRequestHandler::GetExtraResponseInfo(
38 int64* cache_id, GURL* manifest_url) { 38 int64* cache_id, GURL* manifest_url) {
39 if (job_ && job_->is_delivering_appcache_response()) { 39 if (job_ && job_->is_delivering_appcache_response()) {
40 *cache_id = job_->cache_id(); 40 *cache_id = job_->cache_id();
41 *manifest_url = job_->manifest_url(); 41 *manifest_url = job_->manifest_url();
42 } 42 }
43 } 43 }
44 44
45 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadResource( 45 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadResource(
46 net::URLRequest* request, net::NetworkDelegate* network_delegate) { 46 net::URLRequest* request, net::NetworkDelegate* network_delegate) {
47 maybe_load_resource_executed_ = true;
47 if (!host_ || !IsSchemeAndMethodSupported(request) || cache_entry_not_found_) 48 if (!host_ || !IsSchemeAndMethodSupported(request) || cache_entry_not_found_)
48 return NULL; 49 return NULL;
49 50
50 // This method can get called multiple times over the life 51 // This method can get called multiple times over the life
51 // of a request. The case we detect here is having scheduled 52 // of a request. The case we detect here is having scheduled
52 // delivery of a "network response" using a job setup on an 53 // delivery of a "network response" using a job setup on an
53 // earlier call thru this method. To send the request thru 54 // earlier call thru this method. To send the request thru
54 // to the network involves restarting the request altogether, 55 // to the network involves restarting the request altogether,
55 // which will call thru to our interception layer again. 56 // which will call thru to our interception layer again.
56 // This time thru, we return NULL so the request hits the wire. 57 // This time thru, we return NULL so the request hits the wire.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 91
91 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect( 92 AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect(
92 net::URLRequest* request, 93 net::URLRequest* request,
93 net::NetworkDelegate* network_delegate, 94 net::NetworkDelegate* network_delegate,
94 const GURL& location) { 95 const GURL& location) {
95 if (!host_ || !IsSchemeAndMethodSupported(request) || cache_entry_not_found_) 96 if (!host_ || !IsSchemeAndMethodSupported(request) || cache_entry_not_found_)
96 return NULL; 97 return NULL;
97 if (is_main_resource()) 98 if (is_main_resource())
98 return NULL; 99 return NULL;
100 // TODO(vabr) This is a temporary fix (see crbug/141114). We should get rid of
101 // it once a more general solution to crbug/121325 is in place.
102 if (!maybe_load_resource_executed_)
103 return NULL;
99 if (request->url().GetOrigin() == location.GetOrigin()) 104 if (request->url().GetOrigin() == location.GetOrigin())
100 return NULL; 105 return NULL;
101 106
102 DCHECK(!job_); // our jobs never generate redirects 107 DCHECK(!job_); // our jobs never generate redirects
103 108
104 if (found_fallback_entry_.has_response_id()) { 109 if (found_fallback_entry_.has_response_id()) {
105 // 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,
106 // get the resource of the fallback entry. 111 // get the resource of the fallback entry.
107 job_ = new AppCacheURLRequestJob(request, network_delegate, storage()); 112 job_ = new AppCacheURLRequestJob(request, network_delegate, storage());
108 DeliverAppCachedResponse( 113 DeliverAppCachedResponse(
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (!host_->associated_cache() || 367 if (!host_->associated_cache() ||
363 !host_->associated_cache()->is_complete()) { 368 !host_->associated_cache()->is_complete()) {
364 DeliverNetworkResponse(); 369 DeliverNetworkResponse();
365 return; 370 return;
366 } 371 }
367 372
368 ContinueMaybeLoadSubResource(); 373 ContinueMaybeLoadSubResource();
369 } 374 }
370 375
371 } // 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