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

Unified Diff: webkit/quota/quota_manager.cc

Issue 7029007: Implement EvictOriginData in QuotaManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added a. test function. (Not working well, and not reflected the comments.) 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
Index: webkit/quota/quota_manager.cc
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc
index 01f9c75b989cda7a84d7ca6378ca8b0ef2606005..b1c56615b2fedfc1ee0fdcb96e86ef33afce9251 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -14,6 +14,7 @@
#include "base/stl_util-inl.h"
#include "base/sys_info.h"
#include "net/base/net_util.h"
+#include "webkit/quota/quota_client.h"
#include "webkit/quota/quota_database.h"
#include "webkit/quota/quota_types.h"
#include "webkit/quota/usage_tracker.h"
@@ -515,7 +516,10 @@ QuotaManager::QuotaManager(bool is_incognito,
db_disabled_(false),
io_thread_(io_thread),
db_thread_(db_thread),
- temporary_global_quota_(-1) {
+ num_deletion_requested_clients_(0),
+ num_deleted_clients_(0),
+ temporary_global_quota_(-1),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
QuotaManager::~QuotaManager() {
@@ -735,11 +739,53 @@ void QuotaManager::GetLRUOrigin(
task->Start();
}
+void QuotaManager::OnOriginDataEvicted(
+ QuotaStatusCode status) {
+ LOG(ERROR) << "QM::OnOriginDataDeleted";
+ DCHECK(io_thread_->BelongsToCurrentThread());
+
+ if (status != kQuotaStatusOk) {
+ // TODO(dmikurube): Handle error.
+ }
+
+ ++num_deleted_clients_;
+ DCHECK(num_deleted_clients_ <= num_deletion_requested_clients_);
+ if (num_deleted_clients_ == num_deletion_requested_clients_) {
+ num_deletion_requested_clients_ = 0;
+ num_deleted_clients_ = 0;
+
+ // TODO(dmikurube): Get usage, quota and physical space and then callback.
+ evict_origin_data_callback_->Run(kQuotaStatusOk);
+ delete evict_origin_data_callback_;
michaeln 2011/05/17 19:30:01 is the callback leaked if the class is destructed
Dai Mikurube (NOT FULLTIME) 2011/05/18 04:34:48 Done.
+ }
+}
+
void QuotaManager::EvictOriginData(
const GURL& origin,
StorageType type,
EvictOriginDataCallback* callback) {
- // TODO(dmikurube): Implement it.
+ LOG(ERROR) << "QM::DeleteOriginData";
michaeln 2011/05/17 19:30:01 Please fixup the LOG(ERROR) usage throughout. It's
Dai Mikurube (NOT FULLTIME) 2011/05/18 04:34:48 Yeah, I'll remove them finally for other changes.
+ DCHECK(io_thread_->BelongsToCurrentThread());
michaeln 2011/05/17 19:30:01 Since LazyInitialize has this DCHECK, consider rem
Dai Mikurube (NOT FULLTIME) 2011/05/18 04:34:48 LazyInitialize here was replaced with DCHECK(datab
+ LazyInitialize();
+
+ int num_clients = clients_.size();
+
+ if (origin.is_empty() || num_clients == 0 || num_deleted_clients_ > 0) {
+ callback->Run(kQuotaStatusOk);
+ delete callback;
+ return;
+ }
+
+ num_deletion_requested_clients_ = num_clients;
+ num_deleted_clients_ = 0;
+
+ for (QuotaClientList::iterator p = clients_.begin();
+ p != clients_.end();
+ ++p) {
+ evict_origin_data_callback_ = callback;
michaeln 2011/05/17 19:30:01 maybe move this assignment up out of the loop
Dai Mikurube (NOT FULLTIME) 2011/05/18 04:34:48 Done.
+ (*p)->DeleteOriginData(origin, kStorageTypeTemporary, callback_factory_.
+ NewCallback(&QuotaManager::OnOriginDataEvicted));
+ }
}
void QuotaManager::GetUsageAndQuotaForEviction(

Powered by Google App Engine
This is Rietveld 408576698