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

Unified Diff: webkit/quota/quota_manager.cc

Issue 10826270: QuotaManager: Return the remaining free disk space as quota. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 8 years, 4 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
« no previous file with comments | « webkit/quota/quota_manager.h ('k') | webkit/quota/quota_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/quota/quota_manager.cc
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc
index 0028cd38ab23b884b25b02b1d395be3cd538e624..3f9db476ac776debc7a024e1bd60ead35719a303 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -77,11 +77,21 @@ const int QuotaManager::kEvictionIntervalInMilliSeconds =
void CallGetUsageAndQuotaCallback(
const QuotaManager::GetUsageAndQuotaCallback& callback,
bool unlimited,
+ bool is_installed_app,
QuotaStatusCode status,
const QuotaAndUsage& quota_and_usage) {
- int64 usage =
- unlimited ? quota_and_usage.unlimited_usage : quota_and_usage.usage;
- int64 quota = unlimited ? QuotaManager::kNoLimit : quota_and_usage.quota;
+ int64 usage;
+ int64 quota;
+
+ if (unlimited) {
+ usage = quota_and_usage.unlimited_usage;
+ quota = is_installed_app ? quota_and_usage.available_disk_space :
+ QuotaManager::kNoLimit;
+ } else {
+ usage = quota_and_usage.usage;
+ quota = quota_and_usage.quota;
+ }
+
callback.Run(status, usage, quota);
}
@@ -406,6 +416,7 @@ class QuotaManager::UsageAndQuotaDispatcherTaskForPersistent
host(), NewWaitableHostUsageCallback());
manager()->GetPersistentHostQuota(
host(), NewWaitableHostQuotaCallback());
+ manager()->GetAvailableSpace(NewWaitableAvailableSpaceCallback());
}
virtual void DispatchCallbacks() OVERRIDE {
@@ -957,7 +968,9 @@ class QuotaManager::AvailableSpaceQueryTask : public QuotaThreadTask {
: QuotaThreadTask(manager, manager->db_thread_),
profile_path_(manager->profile_path_),
space_(-1),
+ get_disk_space_fn_(manager->get_disk_space_fn_),
callback_(callback) {
+ DCHECK(get_disk_space_fn_);
}
protected:
@@ -965,7 +978,7 @@ class QuotaManager::AvailableSpaceQueryTask : public QuotaThreadTask {
// QuotaThreadTask:
virtual void RunOnTargetThread() OVERRIDE {
- space_ = base::SysInfo::AmountOfFreeDiskSpace(profile_path_);
+ space_ = get_disk_space_fn_(profile_path_);
}
virtual void Aborted() OVERRIDE {
@@ -979,6 +992,7 @@ class QuotaManager::AvailableSpaceQueryTask : public QuotaThreadTask {
private:
FilePath profile_path_;
int64 space_;
+ GetAvailableDiskSpaceFn get_disk_space_fn_;
AvailableSpaceCallback callback_;
};
@@ -1200,7 +1214,8 @@ QuotaManager::QuotaManager(bool is_incognito,
temporary_quota_override_(-1),
desired_available_space_(-1),
special_storage_policy_(special_storage_policy),
- weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ get_disk_space_fn_(&base::SysInfo::AmountOfFreeDiskSpace) {
}
void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) {
@@ -1212,9 +1227,10 @@ void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) {
void QuotaManager::GetUsageAndQuota(
const GURL& origin, StorageType type,
const GetUsageAndQuotaCallback& callback) {
- GetUsageAndQuotaInternal(origin, type, false /* global */,
- base::Bind(&CallGetUsageAndQuotaCallback,
- callback, IsStorageUnlimited(origin)));
+ GetUsageAndQuotaInternal(
+ origin, type, false /* global */,
+ base::Bind(&CallGetUsageAndQuotaCallback, callback,
+ IsStorageUnlimited(origin), IsInstalledApp(origin)));
}
void QuotaManager::GetAvailableSpace(const AvailableSpaceCallback& callback) {
« no previous file with comments | « webkit/quota/quota_manager.h ('k') | webkit/quota/quota_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698