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

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: 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
« 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..e0b19f4e78de67f42cad310b581cbc790f1d2ad3 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -15,6 +15,7 @@
#include "base/stl_util-inl.h"
#include "base/sys_info.h"
#include "net/base/net_util.h"
+#include "webkit/quota/quota_client.h"
kinuko 2011/05/18 05:48:35 nit: this is already included in quota_manager.h
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:04:57 Done.
#include "webkit/quota/quota_database.h"
#include "webkit/quota/quota_types.h"
#include "webkit/quota/usage_tracker.h"
@@ -524,7 +525,10 @@ QuotaManager::QuotaManager(bool is_incognito,
db_disabled_(false),
io_thread_(io_thread),
db_thread_(db_thread),
- temporary_global_quota_(-1) {
+ num_eviction_requested_clients_(0),
+ num_evicted_clients_(0),
+ temporary_global_quota_(-1),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
QuotaManager::~QuotaManager() {
@@ -773,11 +777,51 @@ void QuotaManager::GetLRUOrigin(
task->Start();
}
+void QuotaManager::OnOriginDataEvicted(
+ QuotaStatusCode status) {
+ DCHECK(io_thread_->BelongsToCurrentThread());
+
+ if (status != kQuotaStatusOk) {
+ // TODO(dmikurube): Handle error.
+ }
+
+ ++num_evicted_clients_;
+ DCHECK(num_evicted_clients_ <= num_eviction_requested_clients_);
+ if (num_evicted_clients_ == num_eviction_requested_clients_) {
+ num_eviction_requested_clients_ = 0;
+ num_evicted_clients_ = 0;
+
kinuko 2011/05/18 05:48:35 Here can we call DeleteOriginFromDatabase (if ther
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:04:57 How about add it later? (Since it looks like not
+ evict_origin_data_callback_->Run(kQuotaStatusOk);
+ evict_origin_data_callback_.reset(NULL);
kinuko 2011/05/18 05:48:35 reset() will do (no need to specify NULL)
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:04:57 Done.
+ }
+}
+
void QuotaManager::EvictOriginData(
const GURL& origin,
StorageType type,
EvictOriginDataCallback* callback) {
- // TODO(dmikurube): Implement it.
+ DCHECK(io_thread_->BelongsToCurrentThread());
+ DCHECK(database_.get());
+ DCHECK(num_eviction_requested_clients_ == 0);
+
kinuko 2011/05/18 05:48:35 DCHECK(type == kStorageTypeTemporary) ?
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:04:57 Done.
+ int num_clients = clients_.size();
+
+ if (origin.is_empty() || num_clients == 0) {
+ callback->Run(kQuotaStatusOk);
+ delete callback;
+ return;
+ }
+
+ num_eviction_requested_clients_ = num_clients;
+ num_evicted_clients_ = 0;
+
+ evict_origin_data_callback_.reset(callback);
+ for (QuotaClientList::iterator p = clients_.begin();
+ p != clients_.end();
+ ++p) {
+ (*p)->DeleteOriginData(origin, kStorageTypeTemporary, callback_factory_.
kinuko 2011/05/18 05:48:35 s/kStorageTypeTemporary/type/ ?
Dai Mikurube (NOT FULLTIME) 2011/05/18 06:04:57 Done.
+ NewCallback(&QuotaManager::OnOriginDataEvicted));
+ }
}
void QuotaManager::GetUsageAndQuotaForEviction(
« 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