Chromium Code Reviews| Index: net/reporting/reporting_cache.h |
| diff --git a/net/reporting/reporting_cache.h b/net/reporting/reporting_cache.h |
| index 8d0427983cda959ddf2b626f4fddac36fb96eb75..d32b9973949fc5fad026c48472763c38d4043541 100644 |
| --- a/net/reporting/reporting_cache.h |
| +++ b/net/reporting/reporting_cache.h |
| @@ -107,6 +107,17 @@ class NET_EXPORT ReportingCache { |
| // group. The returned pointers are only guaranteed to be valid if no calls |
| // have been made to |SetClient| or |RemoveEndpoint| in between. |
| // |
| + // If no origin match is found, the cache will return clients from the most |
| + // specific superdomain which contains any clients with includeSubdomains set. |
| + // For example, given the origin https://foo.bar.example.com/, the cache would |
|
shivanisha
2017/04/10 20:08:41
This should be https://foo.bar.baz.com/ based on t
Julia Tuttle
2017/04/12 16:11:37
Done.
|
| + // prioritize each potential match below over the ones below it: |
| + // |
| + // 1. https://foo.bar.baz.com/ (exact origin match) |
| + // 2. https://foo.bar.baz.com:444/ (technically, a superdomain) |
| + // 3. https://bar.baz.com/, https://bar.baz.com:444/, etc. (superdomain) |
| + // 4. https://baz.com/, https://baz.com:444/, etc. (superdomain) |
| + // etc. |
| + // |
| // (Clears any existing data in |*clients_out|.) |
| void GetClientsForOriginAndGroup( |
| const url::Origin& origin, |
| @@ -148,6 +159,15 @@ class NET_EXPORT ReportingCache { |
| } |
| private: |
| + void MaybeAddWildcardClient(const ReportingClient* client); |
| + |
| + void MaybeRemoveWildcardClient(const ReportingClient* client); |
| + |
| + void GetWildcardClientsForDomainAndGroup( |
| + const std::string& domain, |
| + const std::string& group, |
| + std::vector<const ReportingClient*>* clients_out) const; |
| + |
| ReportingContext* context_; |
| // Owns all clients, keyed by origin, then endpoint URL. |
| @@ -156,6 +176,11 @@ class NET_EXPORT ReportingCache { |
| 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::map<std::string, std::unordered_set<const ReportingClient*>> |
| + wildcard_clients_; |
|
shivanisha
2017/04/10 20:08:42
Does std::string has a hash to be able to make thi
Julia Tuttle
2017/04/12 16:11:37
Oh, hey, it does. Good call.
|
| + |
| // Owns all reports, keyed by const raw pointer for easier lookup. |
| std::unordered_map<const ReportingReport*, std::unique_ptr<ReportingReport>> |
| reports_; |