[Eraser strings] Remove unused Supervised User infobar and corresponding strings
[chromium-blink-merge.git] / components / domain_reliability / context_manager.h
blob3e3d5e60535c486beda2c9bf01aaa77b2b36ba34
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_
8 #include <map>
9 #include <string>
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h"
14 #include "components/domain_reliability/beacon.h"
15 #include "components/domain_reliability/config.h"
16 #include "components/domain_reliability/context.h"
17 #include "components/domain_reliability/domain_reliability_export.h"
18 #include "url/gurl.h"
20 namespace domain_reliability {
22 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContextManager {
23 public:
24 DomainReliabilityContextManager(
25 DomainReliabilityContext::Factory* context_factory);
26 ~DomainReliabilityContextManager();
28 // If |url| maps to a context added to this manager, calls |OnBeacon| on
29 // that context with |beacon|. Otherwise, does nothing.
30 void RouteBeacon(const GURL& url, const DomainReliabilityBeacon& beacon);
32 // Calls |ClearBeacons| on all contexts added to this manager, but leaves
33 // the contexts themselves intact.
34 void ClearBeaconsInAllContexts();
36 // TODO(ttuttle): Once unit tests test ContextManager directly, they can use
37 // a custom Context::Factory to get the created Context, and this can be void.
38 DomainReliabilityContext* AddContextForConfig(
39 scoped_ptr<const DomainReliabilityConfig> config);
41 // Removes all contexts from this manager (discarding all queued beacons in
42 // the process).
43 void RemoveAllContexts();
45 scoped_ptr<base::Value> GetWebUIData() const;
47 size_t contexts_size_for_testing() const { return contexts_.size(); }
49 private:
50 typedef std::map<std::string, DomainReliabilityContext*> ContextMap;
52 DomainReliabilityContext* GetContextForHost(const std::string& host);
54 DomainReliabilityContext::Factory* context_factory_;
55 // Owns DomainReliabilityContexts.
56 ContextMap contexts_;
58 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityContextManager);
61 } // namespace domain_reliability
63 #endif // COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_MANAGER_H_