summaryrefslogtreecommitdiffstats
path: root/webkit/quota/quota_manager.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 03:21:10 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 03:21:10 +0000
commit50aef1812c0b96126e27bd2d7718df158ef308dd (patch)
tree720f630716ae57ca7fba553b98e73f2e59e1495c /webkit/quota/quota_manager.cc
parent957973753ec4159003ff7930d946b7e89c7e09f3 (diff)
downloadchromium_src-50aef1812c0b96126e27bd2d7718df158ef308dd.zip
chromium_src-50aef1812c0b96126e27bd2d7718df158ef308dd.tar.gz
chromium_src-50aef1812c0b96126e27bd2d7718df158ef308dd.tar.bz2
Added GetAvailableSpace to QuotaManager
BUG=61676 TEST=QuotaManagerTest.GetAvailableSpaceTest Review URL: http://codereview.chromium.org/7014042 Patch from Taiju Tsuiki <tzik@google.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/quota/quota_manager.cc')
-rw-r--r--webkit/quota/quota_manager.cc42
1 files changed, 41 insertions, 1 deletions
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc
index 2782f6d..6bd37bd 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -4,8 +4,9 @@
#include "webkit/quota/quota_manager.h"
-#include <deque>
#include <algorithm>
+#include <deque>
+#include <set>
#include "base/callback.h"
#include "base/file_path.h"
@@ -570,6 +571,45 @@ void QuotaManager::RequestQuota(
delete callback;
}
+class QuotaManager::AvailableSpaceQueryTask : public QuotaThreadTask {
+ public:
+ AvailableSpaceQueryTask(
+ QuotaManager* manager,
+ scoped_refptr<base::MessageLoopProxy> db_message_loop,
+ const FilePath& profile_path,
+ AvailableSpaceCallback* callback)
+ : QuotaThreadTask(manager, db_message_loop),
+ profile_path_(profile_path),
+ space_(-1),
+ callback_(callback) {}
+ virtual ~AvailableSpaceQueryTask() {}
+
+ protected:
+ virtual void RunOnTargetThread() OVERRIDE {
+ space_ = base::SysInfo::AmountOfFreeDiskSpace(profile_path_);
+ }
+
+ virtual void Aborted() OVERRIDE {
+ callback_->Run(kQuotaErrorAbort, space_);
+ }
+
+ virtual void Completed() OVERRIDE {
+ callback_->Run(kQuotaStatusOk, space_);
+ }
+
+ private:
+ FilePath profile_path_;
+ int64 space_;
+ scoped_ptr<AvailableSpaceCallback> callback_;
+};
+
+
+void QuotaManager::GetAvailableSpace(AvailableSpaceCallback* callback) {
+ scoped_refptr<AvailableSpaceQueryTask> task(
+ new AvailableSpaceQueryTask(this, db_thread_, profile_path_, callback));
+ task->Start();
+}
+
void QuotaManager::GetTemporaryGlobalQuota(QuotaCallback* callback) {
LazyInitialize();
if (temporary_global_quota_ >= 0) {