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

Side by Side Diff: storage/browser/quota/quota_manager.cc

Issue 1221523003: Add a SiteEngagementEvictionPolicy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get_total_engagement_points
Patch Set: remove unnecessary destructor Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "storage/browser/quota/quota_manager.h" 5 #include "storage/browser/quota/quota_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 &unlimited_origins); 1433 &unlimited_origins);
1434 1434
1435 UMA_HISTOGRAM_COUNTS("Quota.NumberOfPersistentStorageOrigins", 1435 UMA_HISTOGRAM_COUNTS("Quota.NumberOfPersistentStorageOrigins",
1436 num_origins); 1436 num_origins);
1437 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedPersistentStorageOrigins", 1437 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedPersistentStorageOrigins",
1438 protected_origins); 1438 protected_origins);
1439 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedPersistentStorageOrigins", 1439 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedPersistentStorageOrigins",
1440 unlimited_origins); 1440 unlimited_origins);
1441 } 1441 }
1442 1442
1443 void QuotaManager::GetLRUOrigin( 1443 void QuotaManager::GetEvictionOrigin(StorageType type,
1444 StorageType type, 1444 const GetOriginCallback& callback) {
1445 const GetLRUOriginCallback& callback) { 1445 GetLRUOrigin(type, callback);
1446 }
1447
1448 void QuotaManager::EvictOriginData(const GURL& origin,
1449 StorageType type,
1450 const EvictOriginDataCallback& callback) {
1451 DCHECK(io_thread_->BelongsToCurrentThread());
1452 DCHECK_EQ(type, kStorageTypeTemporary);
1453
1454 eviction_context_.evicted_origin = origin;
1455 eviction_context_.evicted_type = type;
1456 eviction_context_.evict_origin_data_callback = callback;
1457
1458 DeleteOriginData(origin, type, QuotaClient::kAllClientsMask,
1459 base::Bind(&QuotaManager::DidOriginDataEvicted,
1460 weak_factory_.GetWeakPtr()));
1461 }
1462
1463 void QuotaManager::GetUsageAndQuotaForEviction(
1464 const UsageAndQuotaCallback& callback) {
1465 DCHECK(io_thread_->BelongsToCurrentThread());
1466 LazyInitialize();
1467
1468 UsageAndQuotaCallbackDispatcher* dispatcher =
1469 new UsageAndQuotaCallbackDispatcher(this);
1470 GetUsageTracker(kStorageTypeTemporary)
1471 ->GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback());
1472 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback());
1473 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback());
1474 dispatcher->WaitForResults(callback);
1475 }
1476
1477 void QuotaManager::GetLRUOrigin(StorageType type,
1478 const GetOriginCallback& callback) {
1446 LazyInitialize(); 1479 LazyInitialize();
1447 // This must not be called while there's an in-flight task. 1480 // This must not be called while there's an in-flight task.
1448 DCHECK(lru_origin_callback_.is_null()); 1481 DCHECK(lru_origin_callback_.is_null());
1449 lru_origin_callback_ = callback; 1482 lru_origin_callback_ = callback;
1450 if (db_disabled_) { 1483 if (db_disabled_) {
1451 lru_origin_callback_.Run(GURL()); 1484 lru_origin_callback_.Run(GURL());
1452 lru_origin_callback_.Reset(); 1485 lru_origin_callback_.Reset();
1453 return; 1486 return;
1454 } 1487 }
1455 1488
(...skipping 17 matching lines...) Expand all
1473 base::Bind(&GetLRUOriginOnDBThread, 1506 base::Bind(&GetLRUOriginOnDBThread,
1474 type, 1507 type,
1475 base::Owned(exceptions), 1508 base::Owned(exceptions),
1476 special_storage_policy_, 1509 special_storage_policy_,
1477 base::Unretained(url)), 1510 base::Unretained(url)),
1478 base::Bind(&QuotaManager::DidGetLRUOrigin, 1511 base::Bind(&QuotaManager::DidGetLRUOrigin,
1479 weak_factory_.GetWeakPtr(), 1512 weak_factory_.GetWeakPtr(),
1480 base::Owned(url))); 1513 base::Owned(url)));
1481 } 1514 }
1482 1515
1483 void QuotaManager::EvictOriginData(
1484 const GURL& origin,
1485 StorageType type,
1486 const EvictOriginDataCallback& callback) {
1487 DCHECK(io_thread_->BelongsToCurrentThread());
1488 DCHECK_EQ(type, kStorageTypeTemporary);
1489
1490 eviction_context_.evicted_origin = origin;
1491 eviction_context_.evicted_type = type;
1492 eviction_context_.evict_origin_data_callback = callback;
1493
1494 DeleteOriginData(origin, type, QuotaClient::kAllClientsMask,
1495 base::Bind(&QuotaManager::DidOriginDataEvicted,
1496 weak_factory_.GetWeakPtr()));
1497 }
1498
1499 void QuotaManager::GetUsageAndQuotaForEviction(
1500 const UsageAndQuotaCallback& callback) {
1501 DCHECK(io_thread_->BelongsToCurrentThread());
1502 LazyInitialize();
1503
1504 UsageAndQuotaCallbackDispatcher* dispatcher =
1505 new UsageAndQuotaCallbackDispatcher(this);
1506 GetUsageTracker(kStorageTypeTemporary)->
1507 GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback());
1508 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback());
1509 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback());
1510 dispatcher->WaitForResults(callback);
1511 }
1512
1513 void QuotaManager::DidSetTemporaryGlobalOverrideQuota( 1516 void QuotaManager::DidSetTemporaryGlobalOverrideQuota(
1514 const QuotaCallback& callback, 1517 const QuotaCallback& callback,
1515 const int64* new_quota, 1518 const int64* new_quota,
1516 bool success) { 1519 bool success) {
1517 QuotaStatusCode status = kQuotaErrorInvalidAccess; 1520 QuotaStatusCode status = kQuotaErrorInvalidAccess;
1518 DidDatabaseWork(success); 1521 DidDatabaseWork(success);
1519 if (success) { 1522 if (success) {
1520 temporary_quota_override_ = *new_quota; 1523 temporary_quota_override_ = *new_quota;
1521 status = kQuotaStatusOk; 1524 status = kQuotaStatusOk;
1522 } 1525 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 // |database_|, therefore we can be sure that database_ is alive when this 1625 // |database_|, therefore we can be sure that database_ is alive when this
1623 // task runs. 1626 // task runs.
1624 base::PostTaskAndReplyWithResult( 1627 base::PostTaskAndReplyWithResult(
1625 db_thread_.get(), 1628 db_thread_.get(),
1626 from_here, 1629 from_here,
1627 base::Bind(task, base::Unretained(database_.get())), 1630 base::Bind(task, base::Unretained(database_.get())),
1628 reply); 1631 reply);
1629 } 1632 }
1630 1633
1631 } // namespace storage 1634 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/quota/quota_manager.h ('k') | storage/browser/quota/quota_temporary_storage_evictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698