summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 06:48:49 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 06:48:49 +0000
commit786a47f2b4843dcda1ec8aade3faacfb8aa207c9 (patch)
tree0ecc6925f7db90425b015e09312a6da50f608a61 /webkit
parent9bf35c9981c2ee82476b2fc797913b19f595178c (diff)
downloadchromium_src-786a47f2b4843dcda1ec8aade3faacfb8aa207c9.zip
chromium_src-786a47f2b4843dcda1ec8aade3faacfb8aa207c9.tar.gz
chromium_src-786a47f2b4843dcda1ec8aade3faacfb8aa207c9.tar.bz2
Stop using WeakPtr in SandboxQuotaObserver
BUG=249577 TEST=layout tests NOTRY=true Review URL: https://chromiumcodereview.appspot.com/16848017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/sandbox_quota_observer.cc20
-rw-r--r--webkit/browser/fileapi/sandbox_quota_observer.h5
2 files changed, 13 insertions, 12 deletions
diff --git a/webkit/browser/fileapi/sandbox_quota_observer.cc b/webkit/browser/fileapi/sandbox_quota_observer.cc
index 9098db5..ca7bb08 100644
--- a/webkit/browser/fileapi/sandbox_quota_observer.cc
+++ b/webkit/browser/fileapi/sandbox_quota_observer.cc
@@ -8,6 +8,7 @@
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/file_system_usage_cache.h"
#include "webkit/browser/fileapi/sandbox_mount_point_provider.h"
+#include "webkit/browser/fileapi/timed_task_helper.h"
#include "webkit/browser/quota/quota_client.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/common/fileapi/file_system_util.h"
@@ -22,9 +23,7 @@ SandboxQuotaObserver::SandboxQuotaObserver(
: quota_manager_proxy_(quota_manager_proxy),
update_notify_runner_(update_notify_runner),
sandbox_file_util_(sandbox_file_util),
- file_system_usage_cache_(file_system_usage_cache),
- running_delayed_cache_update_(false),
- weak_factory_(this) {}
+ file_system_usage_cache_(file_system_usage_cache) {}
SandboxQuotaObserver::~SandboxQuotaObserver() {}
@@ -55,11 +54,14 @@ void SandboxQuotaObserver::OnUpdate(const FileSystemURL& url,
return;
pending_update_notification_[usage_file_path] += delta;
- if (!running_delayed_cache_update_) {
- update_notify_runner_->PostTask(FROM_HERE, base::Bind(
- &SandboxQuotaObserver::ApplyPendingUsageUpdate,
- weak_factory_.GetWeakPtr()));
- running_delayed_cache_update_ = true;
+ if (!delayed_cache_update_helper_) {
+ delayed_cache_update_helper_.reset(new TimedTaskHelper(
+ update_notify_runner_));
+ delayed_cache_update_helper_->Start(
+ FROM_HERE,
+ base::TimeDelta(), // No delay.
+ base::Bind(&SandboxQuotaObserver::ApplyPendingUsageUpdate,
+ base::Unretained(this)));
}
}
@@ -120,6 +122,7 @@ base::FilePath SandboxQuotaObserver::GetUsageCachePath(
}
void SandboxQuotaObserver::ApplyPendingUsageUpdate() {
+ delayed_cache_update_helper_.reset();
for (PendingUpdateNotificationMap::iterator itr =
pending_update_notification_.begin();
itr != pending_update_notification_.end();
@@ -127,7 +130,6 @@ void SandboxQuotaObserver::ApplyPendingUsageUpdate() {
UpdateUsageCacheFile(itr->first, itr->second);
}
pending_update_notification_.clear();
- running_delayed_cache_update_ = false;
}
void SandboxQuotaObserver::UpdateUsageCacheFile(
diff --git a/webkit/browser/fileapi/sandbox_quota_observer.h b/webkit/browser/fileapi/sandbox_quota_observer.h
index 908e2b2..2c16860 100644
--- a/webkit/browser/fileapi/sandbox_quota_observer.h
+++ b/webkit/browser/fileapi/sandbox_quota_observer.h
@@ -28,6 +28,7 @@ namespace fileapi {
class FileSystemUsageCache;
class FileSystemURL;
+class TimedTaskHelper;
class ObfuscatedFileUtil;
class SandboxQuotaObserver
@@ -71,9 +72,7 @@ class SandboxQuotaObserver
FileSystemUsageCache* file_system_usage_cache_;
PendingUpdateNotificationMap pending_update_notification_;
- bool running_delayed_cache_update_;
-
- base::WeakPtrFactory<SandboxQuotaObserver> weak_factory_;
+ scoped_ptr<TimedTaskHelper> delayed_cache_update_helper_;
DISALLOW_COPY_AND_ASSIGN(SandboxQuotaObserver);
};