OLD | NEW |
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/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 "webkit/appcache/appcache.h" | 9 #include "webkit/appcache/appcache.h" |
10 #include "webkit/appcache/appcache_backend_impl.h" | 10 #include "webkit/appcache/appcache_backend_impl.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 if (AppCacheRequestHandler::IsMainResourceType(resource_type)) | 245 if (AppCacheRequestHandler::IsMainResourceType(resource_type)) |
246 return new AppCacheRequestHandler(this, resource_type); | 246 return new AppCacheRequestHandler(this, resource_type); |
247 | 247 |
248 if ((associated_cache() && associated_cache()->is_complete()) || | 248 if ((associated_cache() && associated_cache()->is_complete()) || |
249 is_selection_pending()) { | 249 is_selection_pending()) { |
250 return new AppCacheRequestHandler(this, resource_type); | 250 return new AppCacheRequestHandler(this, resource_type); |
251 } | 251 } |
252 return NULL; | 252 return NULL; |
253 } | 253 } |
254 | 254 |
| 255 void AppCacheHost::GetResourceList( |
| 256 std::vector<AppCacheResourceInfo>* resource_infos) { |
| 257 if (associated_cache_.get() && associated_cache_->is_complete()) { |
| 258 for (AppCache::EntryMap::const_iterator it = |
| 259 associated_cache_->entries().begin(); |
| 260 it != associated_cache_->entries().end(); ++it) { |
| 261 AppCacheResourceInfo info; |
| 262 info.url = it->first; |
| 263 info.is_master = it->second.IsMaster(); |
| 264 info.is_manifest = it->second.IsManifest(); |
| 265 info.is_fallback = it->second.IsFallback(); |
| 266 info.is_foreign = it->second.IsForeign(); |
| 267 info.is_explicit = it->second.IsExplicit(); |
| 268 info.size = it->second.response_size(); |
| 269 resource_infos->push_back(info); |
| 270 } |
| 271 } |
| 272 } |
| 273 |
255 Status AppCacheHost::GetStatus() { | 274 Status AppCacheHost::GetStatus() { |
256 // 6.9.8 Application cache API | 275 // 6.9.8 Application cache API |
257 AppCache* cache = associated_cache(); | 276 AppCache* cache = associated_cache(); |
258 if (!cache) | 277 if (!cache) |
259 return UNCACHED; | 278 return UNCACHED; |
260 | 279 |
261 // A cache without an owning group represents the cache being constructed | 280 // A cache without an owning group represents the cache being constructed |
262 // during the application cache update process. | 281 // during the application cache update process. |
263 if (!cache->owning_group()) | 282 if (!cache->owning_group()) |
264 return DOWNLOADING; | 283 return DOWNLOADING; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 blocked_manifest_url_ = manifest_url; | 429 blocked_manifest_url_ = manifest_url; |
411 } | 430 } |
412 | 431 |
413 void AppCacheHost::AssociateCache(AppCache* cache) { | 432 void AppCacheHost::AssociateCache(AppCache* cache) { |
414 if (associated_cache_.get()) { | 433 if (associated_cache_.get()) { |
415 associated_cache_->UnassociateHost(this); | 434 associated_cache_->UnassociateHost(this); |
416 } | 435 } |
417 | 436 |
418 associated_cache_ = cache; | 437 associated_cache_ = cache; |
419 SetSwappableCache(cache ? cache->owning_group() : NULL); | 438 SetSwappableCache(cache ? cache->owning_group() : NULL); |
420 | 439 AppCacheInfo info; |
421 if (cache) { | 440 if (cache) { |
422 cache->AssociateHost(this); | 441 cache->AssociateHost(this); |
423 frontend_->OnCacheSelected(host_id_, cache->cache_id(), GetStatus()); | 442 info.cache_id = cache->cache_id(); |
| 443 info.status = GetStatus(); |
| 444 info.is_complete = cache->is_complete(); |
| 445 if (cache->is_complete()) { |
| 446 // TODO(kkanetkar): Get manifest URL info for NULL owning_group(). |
| 447 info.manifest_url = cache->owning_group()->manifest_url(); |
| 448 info.last_update_time = cache->update_time(); |
| 449 info.creation_time = cache->owning_group()->creation_time(); |
| 450 info.size = cache->cache_size(); |
| 451 } |
| 452 frontend_->OnCacheSelected(host_id_, info); |
424 } else { | 453 } else { |
425 frontend_->OnCacheSelected(host_id_, kNoCacheId, UNCACHED); | 454 // No Cache. |
| 455 frontend_->OnCacheSelected(host_id_, info); |
426 } | 456 } |
427 } | 457 } |
428 | 458 |
429 } // namespace appcache | 459 } // namespace appcache |
OLD | NEW |