OLD | NEW |
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_host.h" | 5 #include "webkit/appcache/appcache_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "webkit/appcache/appcache.h" | 10 #include "webkit/appcache/appcache.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 return new AppCacheRequestHandler(this, resource_type); | 271 return new AppCacheRequestHandler(this, resource_type); |
272 | 272 |
273 if ((associated_cache() && associated_cache()->is_complete()) || | 273 if ((associated_cache() && associated_cache()->is_complete()) || |
274 is_selection_pending()) { | 274 is_selection_pending()) { |
275 return new AppCacheRequestHandler(this, resource_type); | 275 return new AppCacheRequestHandler(this, resource_type); |
276 } | 276 } |
277 return NULL; | 277 return NULL; |
278 } | 278 } |
279 | 279 |
280 void AppCacheHost::GetResourceList( | 280 void AppCacheHost::GetResourceList( |
281 std::vector<AppCacheResourceInfo>* resource_infos) { | 281 AppCacheResourceInfoVector* resource_infos) { |
282 if (associated_cache_.get() && associated_cache_->is_complete()) { | 282 if (associated_cache_.get() && associated_cache_->is_complete()) |
283 for (AppCache::EntryMap::const_iterator it = | 283 associated_cache_->ToResourceInfoVector(resource_infos); |
284 associated_cache_->entries().begin(); | |
285 it != associated_cache_->entries().end(); ++it) { | |
286 AppCacheResourceInfo info; | |
287 info.url = it->first; | |
288 info.is_master = it->second.IsMaster(); | |
289 info.is_manifest = it->second.IsManifest(); | |
290 info.is_fallback = it->second.IsFallback(); | |
291 info.is_foreign = it->second.IsForeign(); | |
292 info.is_explicit = it->second.IsExplicit(); | |
293 info.size = it->second.response_size(); | |
294 resource_infos->push_back(info); | |
295 } | |
296 } | |
297 } | 284 } |
298 | 285 |
299 Status AppCacheHost::GetStatus() { | 286 Status AppCacheHost::GetStatus() { |
300 // 6.9.8 Application cache API | 287 // 6.9.8 Application cache API |
301 AppCache* cache = associated_cache(); | 288 AppCache* cache = associated_cache(); |
302 if (!cache) | 289 if (!cache) |
303 return UNCACHED; | 290 return UNCACHED; |
304 | 291 |
305 // A cache without an owning group represents the cache being constructed | 292 // A cache without an owning group represents the cache being constructed |
306 // during the application cache update process. | 293 // during the application cache update process. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 associated_cache_info_pending_ = cache && !cache->is_complete(); | 467 associated_cache_info_pending_ = cache && !cache->is_complete(); |
481 AppCacheInfo info; | 468 AppCacheInfo info; |
482 if (cache) { | 469 if (cache) { |
483 cache->AssociateHost(this); | 470 cache->AssociateHost(this); |
484 FillCacheInfo(cache, GetStatus(), &info); | 471 FillCacheInfo(cache, GetStatus(), &info); |
485 } | 472 } |
486 frontend_->OnCacheSelected(host_id_, info); | 473 frontend_->OnCacheSelected(host_id_, info); |
487 } | 474 } |
488 | 475 |
489 } // namespace appcache | 476 } // namespace appcache |
OLD | NEW |