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

Unified Diff: webkit/quota/quota_manager.cc

Issue 7039006: Implement GetUsageAndQuotaForEviction in QuotaManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Implemented it and added a test. Created 9 years, 7 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 6bd37bdf6505a19b4a8907ad803b41aeb4f6e6eb..4d54247096ec9349ca801fce35303afa33dfea1b 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -524,7 +524,10 @@ QuotaManager::QuotaManager(bool is_incognito,
db_disabled_(false),
io_thread_(io_thread),
db_thread_(db_thread),
- temporary_global_quota_(-1) {
+ usage_for_eviction_(0),
+ quota_for_eviction_(0),
kinuko 2011/05/18 06:26:55 Now I seriously started wondering if we could have
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:37:20 I agree with that, but how about doing that later
+ temporary_global_quota_(-1),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
QuotaManager::~QuotaManager() {
@@ -780,9 +783,43 @@ void QuotaManager::EvictOriginData(
// TODO(dmikurube): Implement it.
}
+void QuotaManager::OnGetAvailableSpaceForEviction(
+ QuotaStatusCode status,
+ int64 available_space) {
+ get_usage_and_quota_for_eviction_callback_->Run(status,
+ usage_for_eviction_, quota_for_eviction_, available_space);
+ get_usage_and_quota_for_eviction_callback_.reset();
+}
+
+void QuotaManager::OnGetGlobalQuotaForEviction(
+ QuotaStatusCode status,
+ int64 quota) {
+ if (status != kQuotaStatusOk) {
+ get_usage_and_quota_for_eviction_callback_->Run(status,
+ usage_for_eviction_, quota, 0);
+ get_usage_and_quota_for_eviction_callback_.reset();
+ return;
+ }
+
+ quota_for_eviction_ = quota;
+ GetAvailableSpace(callback_factory_.
+ NewCallback(&QuotaManager::OnGetAvailableSpaceForEviction));
kinuko 2011/05/18 06:26:55 We could call all those async methods at once and
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:37:20 Is that a serious requirement? Calling them async
+}
+
+void QuotaManager::OnGetGlobalUsageForEviction(int64 usage) {
+ usage_for_eviction_ = usage;
+ GetTemporaryGlobalQuota(callback_factory_.
+ NewCallback(&QuotaManager::OnGetGlobalQuotaForEviction));
+}
+
void QuotaManager::GetUsageAndQuotaForEviction(
GetUsageAndQuotaForEvictionCallback* callback) {
- // TODO(dmikurube): Implement it.
+ DCHECK(io_thread_->BelongsToCurrentThread());
+
+ get_usage_and_quota_for_eviction_callback_.reset(callback);
+ // TODO(dmikurube): Make kStorageTypeTemporary an argument?
kinuko 2011/05/18 06:26:55 I think we should either add or drop the type para
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:37:20 I think we might want to do that as a refactoring
+ GetGlobalUsage(kStorageTypeTemporary, callback_factory_.
+ NewCallback(&QuotaManager::OnGetGlobalUsageForEviction));
}
void QuotaManager::DeleteOnCorrectThread() const {
« 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