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

Unified Diff: webkit/quota/quota_temporary_storage_evictor.cc

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: choke lint Created 9 years, 3 months 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
Index: webkit/quota/quota_temporary_storage_evictor.cc
diff --git a/webkit/quota/quota_temporary_storage_evictor.cc b/webkit/quota/quota_temporary_storage_evictor.cc
index 49229c3cef1349c5e98ce9cad3d38833e1b6bd63..728ad588dc66a1b4c0b575a766b1a81f7cf2864e 100644
--- a/webkit/quota/quota_temporary_storage_evictor.cc
+++ b/webkit/quota/quota_temporary_storage_evictor.cc
@@ -4,6 +4,9 @@
#include "webkit/quota/quota_temporary_storage_evictor.h"
+#include <algorithm>
+
+#include "base/bind.h"
#include "base/metrics/histogram.h"
#include "googleurl/src/gurl.h"
#include "webkit/quota/quota_manager.h"
@@ -41,7 +44,7 @@ QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor(
quota_eviction_handler_(quota_eviction_handler),
interval_ms_(interval_ms),
repeated_eviction_(true),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
DCHECK(quota_eviction_handler);
}
@@ -143,9 +146,9 @@ void QuotaTemporaryStorageEvictor::ConsiderEviction() {
OnEvictionRoundStarted();
// Get usage and disk space, then continue.
- quota_eviction_handler_->GetUsageAndQuotaForEviction(callback_factory_.
- NewCallback(
- &QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction));
+ quota_eviction_handler_->GetUsageAndQuotaForEviction(
+ base::Bind(&QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction,
+ weak_factory_.GetWeakPtr()));
}
void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction(
@@ -184,8 +187,8 @@ void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction(
// TODO(michaeln): if the reason for eviction is low physical disk space,
// make 'unlimited' origins subject to eviction too.
quota_eviction_handler_->GetLRUOrigin(kStorageTypeTemporary,
- callback_factory_.NewCallback(
- &QuotaTemporaryStorageEvictor::OnGotLRUOrigin));
+ base::Bind(&QuotaTemporaryStorageEvictor::OnGotLRUOrigin,
+ weak_factory_.GetWeakPtr()));
} else {
if (repeated_eviction_) {
// No action required, sleep for a while and check again later.
@@ -215,8 +218,9 @@ void QuotaTemporaryStorageEvictor::OnGotLRUOrigin(const GURL& origin) {
}
quota_eviction_handler_->EvictOriginData(origin, kStorageTypeTemporary,
- callback_factory_.NewCallback(
- &QuotaTemporaryStorageEvictor::OnEvictionComplete));
+ base::Bind(
+ &QuotaTemporaryStorageEvictor::OnEvictionComplete,
+ weak_factory_.GetWeakPtr()));
}
void QuotaTemporaryStorageEvictor::OnEvictionComplete(

Powered by Google App Engine
This is Rietveld 408576698