diff options
Diffstat (limited to 'webkit/appcache/appcache_group.cc')
-rw-r--r-- | webkit/appcache/appcache_group.cc | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/webkit/appcache/appcache_group.cc b/webkit/appcache/appcache_group.cc index 10307c2..67ca4cc 100644 --- a/webkit/appcache/appcache_group.cc +++ b/webkit/appcache/appcache_group.cc @@ -10,21 +10,24 @@ #include "webkit/appcache/appcache.h" #include "webkit/appcache/appcache_host.h" #include "webkit/appcache/appcache_service.h" +#include "webkit/appcache/appcache_update_job.h" namespace appcache { AppCacheGroup::AppCacheGroup(AppCacheService* service, const GURL& manifest_url) - : manifest_url_(manifest_url), - update_status_(IDLE), - is_obsolete_(false), - newest_complete_cache_(NULL), - service_(service) { + : manifest_url_(manifest_url), + update_status_(IDLE), + is_obsolete_(false), + newest_complete_cache_(NULL), + update_job_(NULL), + service_(service) { service_->AddGroup(this); } AppCacheGroup::~AppCacheGroup() { DCHECK(old_caches_.empty()); + DCHECK(!update_job_); // Newest complete cache might never have been associated with a host // and thus would not be cleaned up by the backend impl during shutdown. @@ -34,6 +37,14 @@ AppCacheGroup::~AppCacheGroup() { service_->RemoveGroup(this); } +void AppCacheGroup::AddObserver(Observer* observer) { + observers_.AddObserver(observer); +} + +void AppCacheGroup::RemoveObserver(Observer* observer) { + observers_.RemoveObserver(observer); +} + void AppCacheGroup::AddCache(AppCache* complete_cache) { DCHECK(complete_cache->is_complete()); if (!newest_complete_cache_) { @@ -51,7 +62,6 @@ void AppCacheGroup::AddCache(AppCache* complete_cache) { bool AppCacheGroup::RemoveCache(AppCache* cache) { if (cache == newest_complete_cache_) { - // Cannot remove newest cache if there are older caches as those may // eventually be swapped to the newest cache. if (!old_caches_.empty()) @@ -73,8 +83,27 @@ bool AppCacheGroup::RemoveCache(AppCache* cache) { } void AppCacheGroup::StartUpdateWithNewMasterEntry( - AppCacheHost* host, const GURL& master_entry_url) { - // TODO(michaeln): use the real AppCacheUpdateJob + AppCacheHost* host, const GURL& new_master_resource) { + /* TODO(jennb): enable after have logic for cancelling an update + if (!update_job_) + update_job_ = new AppCacheUpdateJob(service_, this); + + update_job_->StartUpdate(host, new_master_resource); + */ +} + +void AppCacheGroup::SetUpdateStatus(UpdateStatus status) { + if (status == update_status_) + return; + + update_status_ = status; + + if (status != IDLE) { + DCHECK(update_job_); + } else { + update_job_ = NULL; + FOR_EACH_OBSERVER(Observer, observers_, OnUpdateComplete(this)); + } } } // namespace appcache |