Index: webkit/quota/quota_manager.cc |
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc |
index 6bd37bdf6505a19b4a8907ad803b41aeb4f6e6eb..77e51fa6c1cf9d480586ee7248194e162b5b8a1e 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" |
#include "webkit/quota/quota_database.h" |
#include "webkit/quota/quota_types.h" |
#include "webkit/quota/usage_tracker.h" |
@@ -524,11 +525,16 @@ 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() { |
DCHECK(io_thread_->BelongsToCurrentThread()); |
+ if (num_eviction_requested_clients_ > 0) |
+ delete evict_origin_data_callback_; |
proxy_->manager_ = NULL; |
std::for_each(clients_.begin(), clients_.end(), |
std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); |
@@ -773,11 +779,49 @@ 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; |
+ |
+ evict_origin_data_callback_->Run(kQuotaStatusOk); |
+ delete evict_origin_data_callback_; |
+ } |
+} |
+ |
void QuotaManager::EvictOriginData( |
const GURL& origin, |
StorageType type, |
EvictOriginDataCallback* callback) { |
- // TODO(dmikurube): Implement it. |
+ DCHECK(io_thread_->BelongsToCurrentThread()); |
+ DCHECK(database_.get()); |
+ DCHECK(num_evicted_clients_ == 0); |
kinuko
2011/05/18 04:45:12
num_evicted_clients_ == 0 wouldn't guarantee we're
Dai Mikurube (NOT FULLTIME)
2011/05/18 05:08:00
Do you mean DCHECK(num_eviction_requested_clients_
|
+ |
+ num_eviction_requested_clients_ = clients_.size(); |
+ num_evicted_clients_ = 0; |
+ |
+ if (origin.is_empty() || num_eviction_requested_clients_ == 0) { |
+ callback->Run(kQuotaStatusOk); |
+ delete callback; |
+ return; |
+ } |
+ |
+ evict_origin_data_callback_ = callback; |
+ for (QuotaClientList::iterator p = clients_.begin(); |
+ p != clients_.end(); |
+ ++p) { |
+ (*p)->DeleteOriginData(origin, kStorageTypeTemporary, callback_factory_. |
+ NewCallback(&QuotaManager::OnOriginDataEvicted)); |
+ } |
} |
void QuotaManager::GetUsageAndQuotaForEviction( |