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

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

Issue 6546004: Defend against selectCache() being called multiple times.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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/web_application_cache_host_impl.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/web_application_cache_host_impl.h" 5 #include "webkit/appcache/web_application_cache_host_impl.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/id_map.h" 8 #include "base/id_map.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( 66 WebApplicationCacheHostImpl::WebApplicationCacheHostImpl(
67 WebApplicationCacheHostClient* client, 67 WebApplicationCacheHostClient* client,
68 AppCacheBackend* backend) 68 AppCacheBackend* backend)
69 : client_(client), 69 : client_(client),
70 backend_(backend), 70 backend_(backend),
71 ALLOW_THIS_IN_INITIALIZER_LIST(host_id_(g_hosts_map.Get().Add(this))), 71 ALLOW_THIS_IN_INITIALIZER_LIST(host_id_(g_hosts_map.Get().Add(this))),
72 status_(UNCACHED), 72 status_(UNCACHED),
73 is_scheme_supported_(false), 73 is_scheme_supported_(false),
74 is_get_method_(false), 74 is_get_method_(false),
75 is_new_master_entry_(MAYBE) { 75 is_new_master_entry_(MAYBE),
76 was_select_cache_called_(false) {
76 DCHECK(client && backend && (host_id_ != kNoHostId)); 77 DCHECK(client && backend && (host_id_ != kNoHostId));
77 78
78 backend_->RegisterHost(host_id_); 79 backend_->RegisterHost(host_id_);
79 } 80 }
80 81
81 WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() { 82 WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() {
82 backend_->UnregisterHost(host_id_); 83 backend_->UnregisterHost(host_id_);
83 g_hosts_map.Get().Remove(host_id_); 84 g_hosts_map.Get().Remove(host_id_);
84 } 85 }
85 86
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 is_get_method_ = (method == kHttpGETMethod); 165 is_get_method_ = (method == kHttpGETMethod);
165 DCHECK(method == StringToUpperASCII(method)); 166 DCHECK(method == StringToUpperASCII(method));
166 } 167 }
167 168
168 void WebApplicationCacheHostImpl::willStartSubResourceRequest( 169 void WebApplicationCacheHostImpl::willStartSubResourceRequest(
169 WebURLRequest& request) { 170 WebURLRequest& request) {
170 request.setAppCacheHostID(host_id_); 171 request.setAppCacheHostID(host_id_);
171 } 172 }
172 173
173 void WebApplicationCacheHostImpl::selectCacheWithoutManifest() { 174 void WebApplicationCacheHostImpl::selectCacheWithoutManifest() {
175 if (was_select_cache_called_)
176 return;
177 was_select_cache_called_ = true;
178
174 status_ = (document_response_.appCacheID() == kNoCacheId) ? 179 status_ = (document_response_.appCacheID() == kNoCacheId) ?
175 UNCACHED : CHECKING; 180 UNCACHED : CHECKING;
176 is_new_master_entry_ = NO; 181 is_new_master_entry_ = NO;
177 backend_->SelectCache(host_id_, document_url_, 182 backend_->SelectCache(host_id_, document_url_,
178 document_response_.appCacheID(), 183 document_response_.appCacheID(),
179 GURL()); 184 GURL());
180 } 185 }
181 186
182 bool WebApplicationCacheHostImpl::selectCacheWithManifest( 187 bool WebApplicationCacheHostImpl::selectCacheWithManifest(
183 const WebURL& manifest_url) { 188 const WebURL& manifest_url) {
189 if (was_select_cache_called_)
190 return true;
191 was_select_cache_called_ = true;
192
184 GURL manifest_gurl(ClearUrlRef(manifest_url)); 193 GURL manifest_gurl(ClearUrlRef(manifest_url));
185 194
186 // 6.9.6 The application cache selection algorithm 195 // 6.9.6 The application cache selection algorithm
187 // Check for new 'master' entries. 196 // Check for new 'master' entries.
188 if (document_response_.appCacheID() == kNoCacheId) { 197 if (document_response_.appCacheID() == kNoCacheId) {
189 if (is_scheme_supported_ && is_get_method_ && 198 if (is_scheme_supported_ && is_get_method_ &&
190 (manifest_gurl.GetOrigin() == document_url_.GetOrigin())) { 199 (manifest_gurl.GetOrigin() == document_url_.GetOrigin())) {
191 status_ = CHECKING; 200 status_ = CHECKING;
192 is_new_master_entry_ = YES; 201 is_new_master_entry_ = YES;
193 } else { 202 } else {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 web_resources[i].isExplicit = resource_infos[i].is_explicit; 302 web_resources[i].isExplicit = resource_infos[i].is_explicit;
294 web_resources[i].isManifest = resource_infos[i].is_manifest; 303 web_resources[i].isManifest = resource_infos[i].is_manifest;
295 web_resources[i].isForeign = resource_infos[i].is_foreign; 304 web_resources[i].isForeign = resource_infos[i].is_foreign;
296 web_resources[i].isFallback = resource_infos[i].is_fallback; 305 web_resources[i].isFallback = resource_infos[i].is_fallback;
297 web_resources[i].url = resource_infos[i].url; 306 web_resources[i].url = resource_infos[i].url;
298 } 307 }
299 resources->swap(web_resources); 308 resources->swap(web_resources);
300 } 309 }
301 310
302 } // appcache namespace 311 } // appcache namespace
OLDNEW
« no previous file with comments | « webkit/appcache/web_application_cache_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698