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

Side by Side Diff: components/domain_reliability/context_manager.h

Issue 2132563003: Implement origin-based deletion for the domain reliability service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated DomainReliabilityMonitorTest Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_ 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_ 6 #define COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 19 matching lines...) Expand all
30 30
31 // If |url| maps to a context added to this manager, calls |OnBeacon| on 31 // If |url| maps to a context added to this manager, calls |OnBeacon| on
32 // that context with |beacon|. Otherwise, does nothing. 32 // that context with |beacon|. Otherwise, does nothing.
33 void RouteBeacon(std::unique_ptr<DomainReliabilityBeacon> beacon); 33 void RouteBeacon(std::unique_ptr<DomainReliabilityBeacon> beacon);
34 34
35 void SetConfig(const GURL& origin, 35 void SetConfig(const GURL& origin,
36 std::unique_ptr<DomainReliabilityConfig> config, 36 std::unique_ptr<DomainReliabilityConfig> config,
37 base::TimeDelta max_age); 37 base::TimeDelta max_age);
38 void ClearConfig(const GURL& origin); 38 void ClearConfig(const GURL& origin);
39 39
40 // Calls |ClearBeacons| on all contexts added to this manager, but leaves 40 // Calls |ClearBeacons| on all contexts matched by |origin_filter| added
41 // the contexts themselves intact. 41 // to this manager, but leaves the contexts themselves intact. A null
42 void ClearBeaconsInAllContexts(); 42 // |origin_filter| is interpreted as an always-true filter, indicating
43 // complete deletion.
44 void ClearBeacons(const base::Callback<bool(const GURL&)>& origin_filter);
43 45
44 // TODO(juliatuttle): Once unit tests test ContextManager directly, they can 46 // TODO(juliatuttle): Once unit tests test ContextManager directly, they can
45 // use a custom Context::Factory to get the created Context, and this can be 47 // use a custom Context::Factory to get the created Context, and this can be
46 // void. 48 // void.
47 DomainReliabilityContext* AddContextForConfig( 49 DomainReliabilityContext* AddContextForConfig(
48 std::unique_ptr<const DomainReliabilityConfig> config); 50 std::unique_ptr<const DomainReliabilityConfig> config);
49 51
50 // Removes all contexts from this manager (discarding all queued beacons in 52 // Removes all contexts matched by |origin_filter| from this manager
51 // the process). 53 // (discarding all queued beacons in the process). A null |origin_filter|
52 void RemoveAllContexts(); 54 // is interpreted as an always-true filter, indicating complete deletion.
55 void RemoveContexts(const base::Callback<bool(const GURL&)>& origin_filter);
53 56
54 std::unique_ptr<base::Value> GetWebUIData() const; 57 std::unique_ptr<base::Value> GetWebUIData() const;
55 58
56 size_t contexts_size_for_testing() const { return contexts_.size(); } 59 size_t contexts_size_for_testing() const { return contexts_.size(); }
57 60
58 private: 61 private:
59 typedef std::map<std::string, DomainReliabilityContext*> ContextMap; 62 typedef std::map<std::string, DomainReliabilityContext*> ContextMap;
60 63
61 DomainReliabilityContext* GetContextForHost(const std::string& host); 64 DomainReliabilityContext* GetContextForHost(const std::string& host);
62 65
63 DomainReliabilityContext::Factory* context_factory_; 66 DomainReliabilityContext::Factory* context_factory_;
64 // Owns DomainReliabilityContexts. 67 // Owns DomainReliabilityContexts.
65 ContextMap contexts_; 68 ContextMap contexts_;
66 // Currently, Domain Reliability only allows header-based configuration by 69 // Currently, Domain Reliability only allows header-based configuration by
67 // origins that already have baked-in configs. This is the set of origins 70 // origins that already have baked-in configs. This is the set of origins
68 // that have removed their context (by sending "NEL: max-age=0"), so the 71 // that have removed their context (by sending "NEL: max-age=0"), so the
69 // context manager knows they are allowed to set a config again later. 72 // context manager knows they are allowed to set a config again later.
70 std::unordered_set<std::string> removed_contexts_; 73 std::unordered_set<std::string> removed_contexts_;
71 74
72 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityContextManager); 75 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityContextManager);
73 }; 76 };
74 77
75 } // namespace domain_reliability 78 } // namespace domain_reliability
76 79
77 #endif // COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_ 80 #endif // COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover_unittest.cc ('k') | components/domain_reliability/context_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698