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

Unified Diff: chrome/browser/budget_service/budget_database.h

Issue 2199763002: Add in expiring budget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@budget_database
Patch Set: full rebase Created 4 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/budget_service/budget_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/budget_service/budget_database.h
diff --git a/chrome/browser/budget_service/budget_database.h b/chrome/browser/budget_service/budget_database.h
index 0e70b34e2724be02ef610e3110ee26b562702609..239e7fef6cd7d2bcb3d7541d5eeb840821428134 100644
--- a/chrome/browser/budget_service/budget_database.h
+++ b/chrome/browser/budget_service/budget_database.h
@@ -18,6 +18,7 @@
namespace base {
class Clock;
class SequencedTaskRunner;
+class Time;
}
namespace budget_service {
@@ -31,7 +32,7 @@ class GURL;
class BudgetDatabase {
public:
// Data structure for returing the budget decay expectations to the caller.
- using BudgetExpectation = std::list<std::pair<double, double>>;
+ using BudgetExpectation = std::list<std::pair<double, base::Time>>;
// Callback for setting a budget value.
using StoreBudgetCallback = base::Callback<void(bool success)>;
@@ -55,7 +56,8 @@ class BudgetDatabase {
// Add budget for an origin. The caller specifies the amount, and the method
// adds the amount to the cache with the correct expiration. Callback is
- // invoked only after the newly cached value is written to storage.
+ // invoked only after the newly cached value is written to storage. This
+ // should only be called after the budget has been read from the database.
void AddBudget(const GURL& origin,
double amount,
const StoreBudgetCallback& callback);
@@ -67,13 +69,15 @@ class BudgetDatabase {
void SetClockForTesting(std::unique_ptr<base::Clock> clock);
// Data structure for caching budget information.
- using BudgetChunks = std::vector<std::pair<double, double>>;
+ using BudgetChunks = std::vector<std::pair<double, base::Time>>;
using BudgetInfo = std::pair<double, BudgetChunks>;
using AddToCacheCallback = base::Callback<void(bool success)>;
void OnDatabaseInit(bool success);
+ bool IsCached(const GURL& origin) const;
+
void AddToCache(const GURL& origin,
const AddToCacheCallback& callback,
bool success,
@@ -86,6 +90,8 @@ class BudgetDatabase {
void WriteCachedValuesToDatabase(const GURL& origin,
const StoreBudgetCallback& callback);
+ void CleanupExpiredBudget(const GURL& origin);
+
// The database for storing budget information.
std::unique_ptr<leveldb_proto::ProtoDatabase<budget_service::Budget>> db_;
« no previous file with comments | « no previous file | chrome/browser/budget_service/budget_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698