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

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: Updated. 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
« webkit/quota/quota_manager.h ('K') | « webkit/quota/quota_manager.h ('k') | no next file » | 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 7da4480e9ddaef01721f879ecac28e5023eaec40..6c6b1c884bd37472477eddf01685f49fc2aa27d1 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -15,6 +15,7 @@
#include "base/sys_info.h"
#include "net/base/net_util.h"
#include "webkit/quota/quota_database.h"
+#include "webkit/quota/quota_temporary_storage_evictor.h"
#include "webkit/quota/quota_types.h"
#include "webkit/quota/usage_tracker.h"
@@ -494,12 +495,17 @@ QuotaManager::QuotaManager(bool is_incognito,
db_disabled_(false),
io_thread_(io_thread),
db_thread_(db_thread),
+ temporary_storage_evictor_(NULL),
+ num_deletion_requested_clients_(0),
+ num_deleted_clients_(0),
temporary_global_quota_(-1) {
}
QuotaManager::~QuotaManager() {
DCHECK(io_thread_->BelongsToCurrentThread());
proxy_->manager_ = NULL;
+ if (temporary_storage_evictor_ != NULL)
+ temporary_storage_evictor_->OnQuotaManagerDestroyedOnIOThread();
std::for_each(clients_.begin(), clients_.end(),
std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed));
if (database_.get())
@@ -613,6 +619,18 @@ void QuotaManager::SetPersistentHostQuota(const std::string& host,
}
}
+void QuotaManager::RegisterTemporaryStorageEvictor(
+ scoped_refptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor) {
+ /*
+ // TODO(dmikurube): Change this hard-coded 3 seconds.
+ temporary_storage_evictor_ = new QuotaTemporaryStorageEvictor(
+ this, database_.get(), 10000000, 3000, io_thread_, db_thread_);
+ */
+
+ temporary_storage_evictor_ = temporary_storage_evictor;
+ temporary_storage_evictor_->RegisterQuotaManagerOnIOThread(this);
+}
+
void QuotaManager::LazyInitialize() {
DCHECK(io_thread_->BelongsToCurrentThread());
if (database_.get()) {
@@ -680,6 +698,75 @@ void QuotaManager::GetLRUOrigin(
}
}
+void QuotaManager::StartEviction() {
+ LazyInitialize();
+ if (temporary_storage_evictor_ != NULL)
+ temporary_storage_evictor_->Start();
+}
+
+void QuotaManager::GetUsageAndQuotaForEviction(
+ DeleteOriginDataCallback* callback) {
+ const int64 USAGE = 30000;
+ const int64 QUOTA = 100000;
+ const int64 PHYSICAL_AVAILABLE = 1000000000;
+
+ LOG(ERROR) << "QM::GetUsageAndQuotaForEviction";
+ DCHECK(io_thread_->BelongsToCurrentThread());
+ // TODO(dmikurube): Get usage, quota and physical space and then callback.
+ callback->Run(kQuotaStatusOk, USAGE, QUOTA, PHYSICAL_AVAILABLE);
+ delete callback;
+}
+
+void QuotaManager::OnOriginDataDeleted(
+ QuotaStatusCode status,
+ DeleteOriginDataCallback* callback) {
+ 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;
michaeln 2011/05/17 00:19:45 you might be able to do this with one data member
Dai Mikurube (NOT FULLTIME) 2011/05/17 09:18:40 We can do that, but I think these two variables he
+
+ // TODO(dmikurube): Get usage, quota and physical space and then callback.
+ GetUsageAndQuotaForEviction(callback);
+ }
+}
+
+void QuotaManager::DeleteOriginData(
+ const GURL& origin,
+ StorageType type,
+ DeleteOriginDataCallback* callback) {
+ LOG(ERROR) << "QM::DeleteOriginData";
+ DCHECK(io_thread_->BelongsToCurrentThread());
+ LazyInitialize();
+
+ int num_clients = clients_.size();
+
+ if (origin.is_empty() || num_clients == 0 || num_deleted_clients_ > 0) {
+ GetUsageAndQuotaForEviction(callback);
michaeln 2011/05/17 00:19:45 Seems strange to call this method for the last con
Dai Mikurube (NOT FULLTIME) 2011/05/17 09:18:40 I'm separating and re-constructing the change. Le
+ return;
+ }
+
+ num_deletion_requested_clients_ = num_clients;
+ num_deleted_clients_ = 0;
+
+ for (QuotaClientList::iterator p = clients_.begin();
+ p != clients_.end();
+ ++p) {
+ /*
+ p->DeleteOriginData(origin, kStorageTypeTemporary, NewRunnableMethod(
+ this, &QuotaManager::OnOriginDataDeleted));
+ */
+ OnOriginDataDeleted(kQuotaStatusOk, callback); // test.
+ }
+}
+
UsageTracker* QuotaManager::GetUsageTracker(StorageType type) const {
switch (type) {
case kStorageTypeTemporary:
« webkit/quota/quota_manager.h ('K') | « webkit/quota/quota_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698