| Index: storage/browser/quota/quota_manager.cc
|
| diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc
|
| index 52f728086b7169b02f5b62831cf50f7108b6c619..888220431e75a6c2fab7a5a687ba72d8f211c2cd 100644
|
| --- a/storage/browser/quota/quota_manager.cc
|
| +++ b/storage/browser/quota/quota_manager.cc
|
| @@ -73,6 +73,9 @@ int64 QuotaManager::kMinimumPreserveForSystem = 1024 * kMBytes;
|
| const int QuotaManager::kEvictionIntervalInMilliSeconds =
|
| 30 * kMinutesInMilliSeconds;
|
|
|
| +const char QuotaManager::kTimeSinceOriginEvictedHistogram[] =
|
| + "Quota.TimeSinceOriginEvicted";
|
| +
|
| // Heuristics: assuming average cloud server allows a few Gigs storage
|
| // on the server side and the storage needs to be shared for user data
|
| // and by multiple apps.
|
| @@ -152,9 +155,31 @@ bool GetLRUOriginOnDBThread(StorageType type,
|
|
|
| bool DeleteOriginInfoOnDBThread(const GURL& origin,
|
| StorageType type,
|
| + bool is_eviction,
|
| QuotaDatabase* database) {
|
| DCHECK(database);
|
| - return database->DeleteOriginInfo(origin, type);
|
| + if (!database->DeleteOriginInfo(origin, type))
|
| + return false;
|
| +
|
| + // If the deletion is not due to an eviction, delete the entry in the eviction
|
| + // table as well due to privacy concerns.
|
| + if (!is_eviction)
|
| + return database->DeleteOriginLastEvictionTime(origin, type);
|
| +
|
| + base::Time last_eviction_time;
|
| + if (!database->GetOriginLastEvictionTime(origin, type, &last_eviction_time))
|
| + return false;
|
| +
|
| + base::Time now = base::Time::Now();
|
| + if (last_eviction_time != base::Time()) {
|
| + UMA_HISTOGRAM_LONG_TIMES(QuotaManager::kTimeSinceOriginEvictedHistogram,
|
| + now - last_eviction_time);
|
| + }
|
| +
|
| + if (!database->SetOriginLastEvictionTime(origin, type, now))
|
| + return false;
|
| +
|
| + return true;
|
| }
|
|
|
| bool InitializeTemporaryOriginsInfoOnDBThread(const std::set<GURL>* origins,
|
| @@ -534,6 +559,7 @@ class QuotaManager::OriginDataDeleter : public QuotaTask {
|
| const GURL& origin,
|
| StorageType type,
|
| int quota_client_mask,
|
| + bool is_eviction,
|
| const StatusCallback& callback)
|
| : QuotaTask(manager),
|
| origin_(origin),
|
| @@ -542,6 +568,7 @@ class QuotaManager::OriginDataDeleter : public QuotaTask {
|
| error_count_(0),
|
| remaining_clients_(-1),
|
| skipped_clients_(0),
|
| + is_eviction_(is_eviction),
|
| callback_(callback),
|
| weak_factory_(this) {}
|
|
|
| @@ -568,7 +595,7 @@ class QuotaManager::OriginDataDeleter : public QuotaTask {
|
| if (error_count_ == 0) {
|
| // Only remove the entire origin if we didn't skip any client types.
|
| if (skipped_clients_ == 0)
|
| - manager()->DeleteOriginFromDatabase(origin_, type_);
|
| + manager()->DeleteOriginFromDatabase(origin_, type_, is_eviction_);
|
| callback_.Run(kQuotaStatusOk);
|
| } else {
|
| callback_.Run(kQuotaErrorInvalidModification);
|
| @@ -602,6 +629,7 @@ class QuotaManager::OriginDataDeleter : public QuotaTask {
|
| int error_count_;
|
| int remaining_clients_;
|
| int skipped_clients_;
|
| + bool is_eviction_;
|
| StatusCallback callback_;
|
|
|
| base::WeakPtrFactory<OriginDataDeleter> weak_factory_;
|
| @@ -671,11 +699,10 @@ class QuotaManager::HostDataDeleter : public QuotaTask {
|
| for (std::set<GURL>::const_iterator p = origins_.begin();
|
| p != origins_.end();
|
| ++p) {
|
| - OriginDataDeleter* deleter =
|
| - new OriginDataDeleter(
|
| - manager(), *p, type_, quota_client_mask_,
|
| - base::Bind(&HostDataDeleter::DidDeleteOriginData,
|
| - weak_factory_.GetWeakPtr()));
|
| + OriginDataDeleter* deleter = new OriginDataDeleter(
|
| + manager(), *p, type_, quota_client_mask_, false,
|
| + base::Bind(&HostDataDeleter::DidDeleteOriginData,
|
| + weak_factory_.GetWeakPtr()));
|
| deleter->Start();
|
| }
|
| }
|
| @@ -925,9 +952,11 @@ void QuotaManager::SetUsageCacheEnabled(QuotaClient::ID client_id,
|
| GetUsageTracker(type)->SetUsageCacheEnabled(client_id, origin, enabled);
|
| }
|
|
|
| -void QuotaManager::DeleteOriginData(
|
| - const GURL& origin, StorageType type, int quota_client_mask,
|
| - const StatusCallback& callback) {
|
| +void QuotaManager::DeleteOriginData(const GURL& origin,
|
| + StorageType type,
|
| + int quota_client_mask,
|
| + bool is_eviction,
|
| + const StatusCallback& callback) {
|
| LazyInitialize();
|
|
|
| if (origin.is_empty() || clients_.empty()) {
|
| @@ -936,8 +965,8 @@ void QuotaManager::DeleteOriginData(
|
| }
|
|
|
| DCHECK(origin == origin.GetOrigin());
|
| - OriginDataDeleter* deleter =
|
| - new OriginDataDeleter(this, origin, type, quota_client_mask, callback);
|
| + OriginDataDeleter* deleter = new OriginDataDeleter(
|
| + this, origin, type, quota_client_mask, is_eviction, callback);
|
| deleter->Start();
|
| }
|
|
|
| @@ -1354,17 +1383,17 @@ void QuotaManager::StartEviction() {
|
| temporary_storage_evictor_->Start();
|
| }
|
|
|
| -void QuotaManager::DeleteOriginFromDatabase(
|
| - const GURL& origin, StorageType type) {
|
| +void QuotaManager::DeleteOriginFromDatabase(const GURL& origin,
|
| + StorageType type,
|
| + bool is_eviction) {
|
| LazyInitialize();
|
| if (db_disabled_)
|
| return;
|
|
|
| PostTaskAndReplyWithResultForDBThread(
|
| FROM_HERE,
|
| - base::Bind(&DeleteOriginInfoOnDBThread, origin, type),
|
| - base::Bind(&QuotaManager::DidDatabaseWork,
|
| - weak_factory_.GetWeakPtr()));
|
| + base::Bind(&DeleteOriginInfoOnDBThread, origin, type, is_eviction),
|
| + base::Bind(&QuotaManager::DidDatabaseWork, weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| void QuotaManager::DidOriginDataEvicted(QuotaStatusCode status) {
|
| @@ -1455,7 +1484,7 @@ void QuotaManager::EvictOriginData(const GURL& origin,
|
| eviction_context_.evicted_type = type;
|
| eviction_context_.evict_origin_data_callback = callback;
|
|
|
| - DeleteOriginData(origin, type, QuotaClient::kAllClientsMask,
|
| + DeleteOriginData(origin, type, QuotaClient::kAllClientsMask, true,
|
| base::Bind(&QuotaManager::DidOriginDataEvicted,
|
| weak_factory_.GetWeakPtr()));
|
| }
|
|
|