OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 size_t count = fallback_namespaces_.size(); | 224 size_t count = fallback_namespaces_.size(); |
225 for (size_t i = 0; i < count; ++i) { | 225 for (size_t i = 0; i < count; ++i) { |
226 if (StartsWithASCII( | 226 if (StartsWithASCII( |
227 url.spec(), fallback_namespaces_[i].first.spec(), true)) { | 227 url.spec(), fallback_namespaces_[i].first.spec(), true)) { |
228 return &fallback_namespaces_[i]; | 228 return &fallback_namespaces_[i]; |
229 } | 229 } |
230 } | 230 } |
231 return NULL; | 231 return NULL; |
232 } | 232 } |
233 | 233 |
| 234 void AppCache::ToResourceInfoVector(AppCacheResourceInfoVector* infos) const { |
| 235 DCHECK(infos && infos->empty()); |
| 236 for (EntryMap::const_iterator iter = entries_.begin(); |
| 237 iter != entries_.end(); ++iter) { |
| 238 infos->push_back(AppCacheResourceInfo()); |
| 239 AppCacheResourceInfo& info = infos->back(); |
| 240 info.url = iter->first; |
| 241 info.is_master = iter->second.IsMaster(); |
| 242 info.is_manifest = iter->second.IsManifest(); |
| 243 info.is_fallback = iter->second.IsFallback(); |
| 244 info.is_foreign = iter->second.IsForeign(); |
| 245 info.is_explicit = iter->second.IsExplicit(); |
| 246 info.size = iter->second.response_size(); |
| 247 info.response_id = iter->second.response_id(); |
| 248 } |
| 249 } |
| 250 |
234 // static | 251 // static |
235 bool AppCache::IsInNetworkNamespace( | 252 bool AppCache::IsInNetworkNamespace( |
236 const GURL& url, | 253 const GURL& url, |
237 const std::vector<GURL> &namespaces) { | 254 const std::vector<GURL> &namespaces) { |
238 // TODO(michaeln): There are certainly better 'prefix matching' | 255 // TODO(michaeln): There are certainly better 'prefix matching' |
239 // structures and algorithms that can be applied here and above. | 256 // structures and algorithms that can be applied here and above. |
240 size_t count = namespaces.size(); | 257 size_t count = namespaces.size(); |
241 for (size_t i = 0; i < count; ++i) { | 258 for (size_t i = 0; i < count; ++i) { |
242 if (StartsWithASCII(url.spec(), namespaces[i].spec(), true)) | 259 if (StartsWithASCII(url.spec(), namespaces[i].spec(), true)) |
243 return true; | 260 return true; |
244 } | 261 } |
245 return false; | 262 return false; |
246 } | 263 } |
247 | 264 |
248 } // namespace appcache | 265 } // namespace appcache |
OLD | NEW |