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

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

Issue 10575044: AppCache - Don't ignore network namespace entries when '*' is in the list. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "webkit/appcache/appcache.h" 7 #include "webkit/appcache/appcache.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 fallback.target_url)); 145 fallback.target_url));
146 } 146 }
147 147
148 // Sort the fallback namespaces by url string length, longest to shortest, 148 // Sort the fallback namespaces by url string length, longest to shortest,
149 // since longer matches trump when matching a url to a namespace. 149 // since longer matches trump when matching a url to a namespace.
150 std::sort(intercept_namespaces_.begin(), intercept_namespaces_.end(), 150 std::sort(intercept_namespaces_.begin(), intercept_namespaces_.end(),
151 SortNamespacesByLength); 151 SortNamespacesByLength);
152 std::sort(fallback_namespaces_.begin(), fallback_namespaces_.end(), 152 std::sort(fallback_namespaces_.begin(), fallback_namespaces_.end(),
153 SortNamespacesByLength); 153 SortNamespacesByLength);
154 154
155 if (!online_whitelist_all_) { 155 for (size_t i = 0; i < whitelists.size(); ++i)
156 for (size_t i = 0; i < whitelists.size(); ++i) { 156 online_whitelist_namespaces_.push_back(whitelists.at(i).namespace_url);
157 online_whitelist_namespaces_.push_back(whitelists.at(i).namespace_url);
158 }
159 }
160 } 157 }
161 158
162 void AppCache::ToDatabaseRecords( 159 void AppCache::ToDatabaseRecords(
163 const AppCacheGroup* group, 160 const AppCacheGroup* group,
164 AppCacheDatabase::CacheRecord* cache_record, 161 AppCacheDatabase::CacheRecord* cache_record,
165 std::vector<AppCacheDatabase::EntryRecord>* entries, 162 std::vector<AppCacheDatabase::EntryRecord>* entries,
166 std::vector<AppCacheDatabase::NamespaceRecord>* intercepts, 163 std::vector<AppCacheDatabase::NamespaceRecord>* intercepts,
167 std::vector<AppCacheDatabase::NamespaceRecord>* fallbacks, 164 std::vector<AppCacheDatabase::NamespaceRecord>* fallbacks,
168 std::vector<AppCacheDatabase::OnlineWhiteListRecord>* whitelists) { 165 std::vector<AppCacheDatabase::OnlineWhiteListRecord>* whitelists) {
169 DCHECK(group && cache_record && entries && fallbacks && whitelists); 166 DCHECK(group && cache_record && entries && fallbacks && whitelists);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 for (size_t i = 0; i < fallback_namespaces_.size(); ++i) { 199 for (size_t i = 0; i < fallback_namespaces_.size(); ++i) {
203 fallbacks->push_back(AppCacheDatabase::NamespaceRecord()); 200 fallbacks->push_back(AppCacheDatabase::NamespaceRecord());
204 AppCacheDatabase::NamespaceRecord& record = fallbacks->back(); 201 AppCacheDatabase::NamespaceRecord& record = fallbacks->back();
205 record.cache_id = cache_id_; 202 record.cache_id = cache_id_;
206 record.origin = origin; 203 record.origin = origin;
207 record.type = FALLBACK_NAMESPACE; 204 record.type = FALLBACK_NAMESPACE;
208 record.namespace_url = fallback_namespaces_[i].namespace_url; 205 record.namespace_url = fallback_namespaces_[i].namespace_url;
209 record.target_url = fallback_namespaces_[i].target_url; 206 record.target_url = fallback_namespaces_[i].target_url;
210 } 207 }
211 208
212 if (!online_whitelist_all_) { 209 for (size_t i = 0; i < online_whitelist_namespaces_.size(); ++i) {
213 for (size_t i = 0; i < online_whitelist_namespaces_.size(); ++i) { 210 whitelists->push_back(AppCacheDatabase::OnlineWhiteListRecord());
214 whitelists->push_back(AppCacheDatabase::OnlineWhiteListRecord()); 211 AppCacheDatabase::OnlineWhiteListRecord& record = whitelists->back();
215 AppCacheDatabase::OnlineWhiteListRecord& record = whitelists->back(); 212 record.cache_id = cache_id_;
216 record.cache_id = cache_id_; 213 record.namespace_url = online_whitelist_namespaces_[i];
217 record.namespace_url = online_whitelist_namespaces_[i];
218 }
219 } 214 }
220 } 215 }
221 216
222 bool AppCache::FindResponseForRequest(const GURL& url, 217 bool AppCache::FindResponseForRequest(const GURL& url,
223 AppCacheEntry* found_entry, GURL* found_intercept_namespace, 218 AppCacheEntry* found_entry, GURL* found_intercept_namespace,
224 AppCacheEntry* found_fallback_entry, GURL* found_fallback_namespace, 219 AppCacheEntry* found_fallback_entry, GURL* found_fallback_namespace,
225 bool* found_network_namespace) { 220 bool* found_network_namespace) {
226 // Ignore fragments when looking up URL in the cache. 221 // Ignore fragments when looking up URL in the cache.
227 GURL url_no_ref; 222 GURL url_no_ref;
228 if (url.has_ref()) { 223 if (url.has_ref()) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // structures and algorithms that can be applied here and above. 301 // structures and algorithms that can be applied here and above.
307 size_t count = namespaces.size(); 302 size_t count = namespaces.size();
308 for (size_t i = 0; i < count; ++i) { 303 for (size_t i = 0; i < count; ++i) {
309 if (StartsWithASCII(url.spec(), namespaces[i].spec(), true)) 304 if (StartsWithASCII(url.spec(), namespaces[i].spec(), true))
310 return true; 305 return true;
311 } 306 }
312 return false; 307 return false;
313 } 308 }
314 309
315 } // namespace appcache 310 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698