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

Unified Diff: net/reporting/reporting_cache.h

Issue 2851603002: Reporting: Cap number of clients in cache. (Closed)
Patch Set: Make requested change. Created 3 years, 7 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 | net/reporting/reporting_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_cache.h
diff --git a/net/reporting/reporting_cache.h b/net/reporting/reporting_cache.h
index 122e0c81beaa662eaa44e0c9cc39297522b95311..1a5d31d8328c60157ddabe98c1f5311d82736027 100644
--- a/net/reporting/reporting_cache.h
+++ b/net/reporting/reporting_cache.h
@@ -22,6 +22,10 @@
#include "url/gurl.h"
#include "url/origin.h"
+namespace base {
+class TickClock;
+} // namespace base
+
namespace net {
class ReportingContext;
@@ -98,6 +102,8 @@ class NET_EXPORT ReportingCache {
const std::string& group,
base::TimeTicks expires);
+ void MarkClientUsed(const url::Origin& origin, const GURL& endpoint);
+
// Gets all of the clients in the cache, regardless of origin or group.
//
// (Clears any existing data in |*clients_out|.)
@@ -161,27 +167,25 @@ class NET_EXPORT ReportingCache {
private:
const ReportingReport* FindReportToEvict() const;
- void MaybeAddWildcardClient(const ReportingClient* client);
+ void AddClient(std::unique_ptr<ReportingClient> client,
+ base::TimeTicks last_used);
- void MaybeRemoveWildcardClient(const ReportingClient* client);
+ void RemoveClient(const ReportingClient* client);
+
+ const ReportingClient* GetClientByOriginAndEndpoint(
+ const url::Origin& origin,
+ const GURL& endpoint) const;
void GetWildcardClientsForDomainAndGroup(
const std::string& domain,
const std::string& group,
std::vector<const ReportingClient*>* clients_out) const;
- ReportingContext* context_;
+ const ReportingClient* FindClientToEvict(base::TimeTicks now) const;
- // Owns all clients, keyed by origin, then endpoint URL.
- // (These would be unordered_map, but neither url::Origin nor GURL has a hash
- // function implemented.)
- std::map<url::Origin, std::map<GURL, std::unique_ptr<ReportingClient>>>
- clients_;
+ base::TickClock* tick_clock();
- // References but does not own all clients with includeSubdomains set, keyed
- // by domain name.
- std::unordered_map<std::string, std::unordered_set<const ReportingClient*>>
- wildcard_clients_;
+ ReportingContext* context_;
// Owns all reports, keyed by const raw pointer for easier lookup.
std::unordered_map<const ReportingReport*, std::unique_ptr<ReportingReport>>
@@ -195,6 +199,20 @@ class NET_EXPORT ReportingCache {
// pending when the deletion was requested).
std::unordered_set<const ReportingReport*> doomed_reports_;
+ // Owns all clients, keyed by origin, then endpoint URL.
+ // (These would be unordered_map, but neither url::Origin nor GURL has a hash
+ // function implemented.)
+ std::map<url::Origin, std::map<GURL, std::unique_ptr<ReportingClient>>>
+ clients_;
+
+ // References but does not own all clients with includeSubdomains set, keyed
+ // by domain name.
+ std::unordered_map<std::string, std::unordered_set<const ReportingClient*>>
+ wildcard_clients_;
+
+ // The time that each client has last been used.
+ std::unordered_map<const ReportingClient*, base::TimeTicks> client_last_used_;
+
DISALLOW_COPY_AND_ASSIGN(ReportingCache);
};
« no previous file with comments | « no previous file | net/reporting/reporting_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698