summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_host.cc
diff options
context:
space:
mode:
authorkkanetkar@chromium.org <kkanetkar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-05 18:22:36 +0000
committerkkanetkar@chromium.org <kkanetkar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-05 18:22:36 +0000
commit4164a7311d49382ae3ec1117de53de2fc3517bb7 (patch)
tree255c05aaa0c609dbbec86e57fee6792eb019eae5 /webkit/appcache/appcache_host.cc
parent145f6e49cd5ce6cb6718188eb61380a0b3daac1f (diff)
downloadchromium_src-4164a7311d49382ae3ec1117de53de2fc3517bb7.zip
chromium_src-4164a7311d49382ae3ec1117de53de2fc3517bb7.tar.gz
chromium_src-4164a7311d49382ae3ec1117de53de2fc3517bb7.tar.bz2
Sending renderer notification when update job finishes (Used to notify cache complete).
OnCacheSelected() event caches appcache info in appcache host. This info is returned for appcache inspection by devtools. BUG = None TEST = Manual Review URL: http://codereview.chromium.org/3074015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_host.cc')
-rw-r--r--webkit/appcache/appcache_host.cc45
1 files changed, 30 insertions, 15 deletions
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc
index 66cf2a8..1f1b5da 100644
--- a/webkit/appcache/appcache_host.cc
+++ b/webkit/appcache/appcache_host.cc
@@ -12,6 +12,24 @@
namespace appcache {
+namespace {
+
+void FillCacheInfo(
+ const AppCache* cache, Status status, AppCacheInfo* info) {
+ DCHECK(cache);
+ info->cache_id = cache->cache_id();
+ info->status = status;
+ info->is_complete = cache->is_complete();
+ if (info->is_complete) {
+ info->manifest_url = cache->owning_group()->manifest_url();
+ info->last_update_time = cache->update_time();
+ info->creation_time = cache->owning_group()->creation_time();
+ info->size = cache->cache_size();
+ }
+}
+
+} // Anonymous namespace
+
AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend,
AppCacheService* service)
: host_id_(host_id), parent_host_id_(kNoHostId), parent_process_id_(0),
@@ -20,7 +38,7 @@ AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend,
frontend_(frontend), service_(service),
pending_get_status_callback_(NULL), pending_start_update_callback_(NULL),
pending_swap_cache_callback_(NULL), pending_callback_param_(NULL),
- main_resource_blocked_(false) {
+ main_resource_blocked_(false), associated_cache_info_pending_(false) {
}
AppCacheHost::~AppCacheHost() {
@@ -396,6 +414,14 @@ void AppCacheHost::OnUpdateComplete(AppCacheGroup* group) {
group_being_updated_ = NULL;
newest_cache_of_group_being_updated_ = NULL;
+
+ if (associated_cache_info_pending_ && associated_cache_.get() &&
+ associated_cache_->is_complete()) {
+ AppCacheInfo info;
+ FillCacheInfo(associated_cache_.get(), GetStatus(), &info);
+ associated_cache_info_pending_ = false;
+ frontend_->OnCacheSelected(host_id_, info);
+ }
}
void AppCacheHost::OnContentBlocked(AppCacheGroup* group) {
@@ -436,24 +462,13 @@ void AppCacheHost::AssociateCache(AppCache* cache) {
associated_cache_ = cache;
SetSwappableCache(cache ? cache->owning_group() : NULL);
+ associated_cache_info_pending_ = cache && !cache->is_complete();
AppCacheInfo info;
if (cache) {
cache->AssociateHost(this);
- info.cache_id = cache->cache_id();
- info.status = GetStatus();
- info.is_complete = cache->is_complete();
- if (cache->is_complete()) {
- // TODO(kkanetkar): Get manifest URL info for NULL owning_group().
- info.manifest_url = cache->owning_group()->manifest_url();
- info.last_update_time = cache->update_time();
- info.creation_time = cache->owning_group()->creation_time();
- info.size = cache->cache_size();
- }
- frontend_->OnCacheSelected(host_id_, info);
- } else {
- // No Cache.
- frontend_->OnCacheSelected(host_id_, info);
+ FillCacheInfo(cache, GetStatus(), &info);
}
+ frontend_->OnCacheSelected(host_id_, info);
}
} // namespace appcache