Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1024)

Unified Diff: webkit/appcache/appcache_group.cc

Issue 8673008: base::Bind: Implement CancelableCallback to replace CancelableTaske. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test build fix. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/appcache/appcache_group.h ('k') | webkit/appcache/appcache_group_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/appcache/appcache_group.cc
diff --git a/webkit/appcache/appcache_group.cc b/webkit/appcache/appcache_group.cc
index cdc6a703f7e28052a50c72fd05ff120e20deafc7..05e1ac5329fb8373860e099cf5e9f30f389cc049 100644
--- a/webkit/appcache/appcache_group.cc
+++ b/webkit/appcache/appcache_group.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "webkit/appcache/appcache.h"
@@ -45,7 +46,6 @@ AppCacheGroup::AppCacheGroup(AppCacheService* service,
newest_complete_cache_(NULL),
update_job_(NULL),
service_(service),
- restart_update_task_(NULL),
is_in_dtor_(false) {
service_->storage()->working_set()->AddGroup(this);
host_observer_.reset(new HostObserver(this));
@@ -54,7 +54,7 @@ AppCacheGroup::AppCacheGroup(AppCacheService* service,
AppCacheGroup::~AppCacheGroup() {
DCHECK(old_caches_.empty());
DCHECK(!newest_complete_cache_);
- DCHECK(!restart_update_task_);
+ DCHECK(restart_update_task_.IsCancelled());
DCHECK(queued_updates_.empty());
is_in_dtor_ = true;
@@ -166,9 +166,8 @@ void AppCacheGroup::StartUpdateWithNewMasterEntry(
update_job_->StartUpdate(host, new_master_resource);
// Run queued update immediately as an update has been started manually.
- if (restart_update_task_) {
- restart_update_task_->Cancel();
- restart_update_task_ = NULL;
+ if (!restart_update_task_.IsCancelled()) {
+ restart_update_task_.Cancel();
RunQueuedUpdates();
}
}
@@ -198,8 +197,8 @@ void AppCacheGroup::QueueUpdate(AppCacheHost* host,
}
void AppCacheGroup::RunQueuedUpdates() {
- if (restart_update_task_)
- restart_update_task_ = NULL;
+ if (!restart_update_task_.IsCancelled())
+ restart_update_task_.Cancel();
if (queued_updates_.empty())
return;
@@ -228,19 +227,17 @@ bool AppCacheGroup::FindObserver(UpdateObserver* find_me,
}
void AppCacheGroup::ScheduleUpdateRestart(int delay_ms) {
- DCHECK(!restart_update_task_);
- restart_update_task_ =
- NewRunnableMethod(this, &AppCacheGroup::RunQueuedUpdates);
- MessageLoop::current()->PostDelayedTask(FROM_HERE, restart_update_task_,
- delay_ms);
+ DCHECK(restart_update_task_.IsCancelled());
+ restart_update_task_.Reset(
+ base::Bind(&AppCacheGroup::RunQueuedUpdates, this));
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, restart_update_task_.callback(), delay_ms);
}
void AppCacheGroup::HostDestructionImminent(AppCacheHost* host) {
queued_updates_.erase(host);
- if (queued_updates_.empty() && restart_update_task_) {
- restart_update_task_->Cancel();
- restart_update_task_ = NULL;
- }
+ if (queued_updates_.empty() && !restart_update_task_.IsCancelled())
+ restart_update_task_.Cancel();
}
void AppCacheGroup::SetUpdateStatus(UpdateStatus status) {
« no previous file with comments | « webkit/appcache/appcache_group.h ('k') | webkit/appcache/appcache_group_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698