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

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: Created 5 years, 5 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(
1444 StorageType type, 1444 StorageType type,
1445 const GetLRUOriginCallback& callback) { 1445 const GetEvictionOriginCallback& callback) {
1446 GetLRUOrigin(type, callback);
1447 }
1448
1449 void QuotaManager::EvictOriginData(const GURL& origin,
1450 StorageType type,
1451 const EvictOriginDataCallback& callback) {
1452 DCHECK(io_thread_->BelongsToCurrentThread());
1453 DCHECK_EQ(type, kStorageTypeTemporary);
1454
1455 eviction_context_.evicted_origin = origin;
1456 eviction_context_.evicted_type = type;
1457 eviction_context_.evict_origin_data_callback = callback;
1458
1459 DeleteOriginData(origin, type, QuotaClient::kAllClientsMask,
1460 base::Bind(&QuotaManager::DidOriginDataEvicted,
1461 weak_factory_.GetWeakPtr()));
1462 }
1463
1464 void QuotaManager::GetUsageAndQuotaForEviction(
1465 const UsageAndQuotaCallback& callback) {
1466 DCHECK(io_thread_->BelongsToCurrentThread());
1467 LazyInitialize();
1468
1469 UsageAndQuotaCallbackDispatcher* dispatcher =
1470 new UsageAndQuotaCallbackDispatcher(this);
1471 GetUsageTracker(kStorageTypeTemporary)
1472 ->GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback());
1473 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback());
1474 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback());
1475 dispatcher->WaitForResults(callback);
1476 }
raymes 2015/07/08 04:43:29 Were these 2 functions just moved to fix ordering?
calamity 2015/07/10 05:05:05 Yup. Shame there's no way to indicate that =(
1477
1478 void QuotaManager::GetLRUOrigin(StorageType type,
1479 const GetEvictionOriginCallback& callback) {
1446 LazyInitialize(); 1480 LazyInitialize();
1447 // This must not be called while there's an in-flight task. 1481 // This must not be called while there's an in-flight task.
1448 DCHECK(lru_origin_callback_.is_null()); 1482 DCHECK(lru_origin_callback_.is_null());
1449 lru_origin_callback_ = callback; 1483 lru_origin_callback_ = callback;
1450 if (db_disabled_) { 1484 if (db_disabled_) {
1451 lru_origin_callback_.Run(GURL()); 1485 lru_origin_callback_.Run(GURL());
1452 lru_origin_callback_.Reset(); 1486 lru_origin_callback_.Reset();
1453 return; 1487 return;
1454 } 1488 }
1455 1489
(...skipping 17 matching lines...) Expand all
1473 base::Bind(&GetLRUOriginOnDBThread, 1507 base::Bind(&GetLRUOriginOnDBThread,
1474 type, 1508 type,
1475 base::Owned(exceptions), 1509 base::Owned(exceptions),
1476 special_storage_policy_, 1510 special_storage_policy_,
1477 base::Unretained(url)), 1511 base::Unretained(url)),
1478 base::Bind(&QuotaManager::DidGetLRUOrigin, 1512 base::Bind(&QuotaManager::DidGetLRUOrigin,
1479 weak_factory_.GetWeakPtr(), 1513 weak_factory_.GetWeakPtr(),
1480 base::Owned(url))); 1514 base::Owned(url)));
1481 } 1515 }
1482 1516
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( 1517 void QuotaManager::DidSetTemporaryGlobalOverrideQuota(
1514 const QuotaCallback& callback, 1518 const QuotaCallback& callback,
1515 const int64* new_quota, 1519 const int64* new_quota,
1516 bool success) { 1520 bool success) {
1517 QuotaStatusCode status = kQuotaErrorInvalidAccess; 1521 QuotaStatusCode status = kQuotaErrorInvalidAccess;
1518 DidDatabaseWork(success); 1522 DidDatabaseWork(success);
1519 if (success) { 1523 if (success) {
1520 temporary_quota_override_ = *new_quota; 1524 temporary_quota_override_ = *new_quota;
1521 status = kQuotaStatusOk; 1525 status = kQuotaStatusOk;
1522 } 1526 }
(...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 1626 // |database_|, therefore we can be sure that database_ is alive when this
1623 // task runs. 1627 // task runs.
1624 base::PostTaskAndReplyWithResult( 1628 base::PostTaskAndReplyWithResult(
1625 db_thread_.get(), 1629 db_thread_.get(),
1626 from_here, 1630 from_here,
1627 base::Bind(task, base::Unretained(database_.get())), 1631 base::Bind(task, base::Unretained(database_.get())),
1628 reply); 1632 reply);
1629 } 1633 }
1630 1634
1631 } // namespace storage 1635 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698