summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_group.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-29 00:38:01 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-29 00:38:01 +0000
commita6a27b9526c42e2f68d261b9896627cc41a428de (patch)
tree1aaa961dbe16247288b76bacf58b6c6b6d75d90f /webkit/appcache/appcache_group.cc
parentddcd5e3b2cd813bc21befe70f8faf6eb65dd3829 (diff)
downloadchromium_src-a6a27b9526c42e2f68d261b9896627cc41a428de.zip
chromium_src-a6a27b9526c42e2f68d261b9896627cc41a428de.tar.gz
chromium_src-a6a27b9526c42e2f68d261b9896627cc41a428de.tar.bz2
Revert 37466 - Fix a refcounting memory bug.
BUG=none TEST=none Review URL: http://codereview.chromium.org/552222 TBR=michaeln@chromium.org, victorw@chromium.org Review URL: http://codereview.chromium.org/556067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37469 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_group.cc')
-rw-r--r--webkit/appcache/appcache_group.cc22
1 files changed, 10 insertions, 12 deletions
diff --git a/webkit/appcache/appcache_group.cc b/webkit/appcache/appcache_group.cc
index 0b3f496..e1906ab 100644
--- a/webkit/appcache/appcache_group.cc
+++ b/webkit/appcache/appcache_group.cc
@@ -245,18 +245,16 @@ void AppCacheGroup::SetUpdateStatus(UpdateStatus status) {
} else {
update_job_ = NULL;
- // Note, this method may be called from within our destructor so we have
- // to be careful about calling addref and release in here. If there are
- // any observers, this will not be the case since each observer will have
- // a reference to us.
- if (observers_.size() || queued_observers_.size()) {
- // Observers may release us in these callbacks, so we protect against
- // deletion by adding an extra ref in this scope.
- scoped_refptr<AppCacheGroup> protect(this);
- FOR_EACH_OBSERVER(UpdateObserver, observers_, OnUpdateComplete(this));
- if (!queued_updates_.empty())
- ScheduleUpdateRestart(kUpdateRestartDelayMs);
- }
+ // Check member variable before notifying observers about update finishing.
+ // Observers may remove reference to group, causing group to be deleted
+ // after the notifications. If there are queued updates, then the group
+ // will continue to exist.
+ bool restart_update = !queued_updates_.empty();
+
+ FOR_EACH_OBSERVER(UpdateObserver, observers_, OnUpdateComplete(this));
+
+ if (restart_update)
+ ScheduleUpdateRestart(kUpdateRestartDelayMs);
}
}