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

Side by Side Diff: net/reporting/reporting_endpoint_manager.h

Issue 2737483004: Reporting: Implement endpoint manager. (Closed)
Patch Set: rebase Created 3 years, 9 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
« no previous file with comments | « net/BUILD.gn ('k') | net/reporting/reporting_endpoint_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #ifndef NET_REPORTING_REPORTING_ENDPOINT_MANAGER_H_
6 #define NET_REPORTING_REPORTING_ENDPOINT_MANAGER_H_
7
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <string>
12
13 #include "base/macros.h"
14 #include "base/time/tick_clock.h"
15 #include "net/base/backoff_entry.h"
16 #include "net/base/net_export.h"
17 #include "url/gurl.h"
18 #include "url/origin.h"
19
20 namespace net {
21
22 class ReportingCache;
23
24 // Keeps track of which endpoints are pending (have active delivery attempts to
25 // them) or in exponential backoff after one or more failures, and chooses an
26 // endpoint from an endpoint group to receive reports for an origin.
27 class NET_EXPORT ReportingEndpointManager {
28 public:
29 ReportingEndpointManager(base::TickClock* clock,
30 const ReportingCache* cache,
31 const BackoffEntry::Policy* backoff_policy);
shivanisha 2017/03/20 19:06:51 Document the lifetime of clock, cache and backoff_
Julia Tuttle 2017/03/21 21:43:03 Done.
32 ~ReportingEndpointManager();
33
34 // Finds an endpoint configured by |origin| in group |group| that is not
35 // pending, backed-off (according to BackoffEntry), or expired.
36 //
37 // Deliberately chooses an endpoint randomly to ensure sites aren't relying on
38 // any sort of fallback ordering.
39 //
40 // Returns true and sets |*endpoint_url_out| to the endpoint URL if an
41 // endpoint was chosen; returns false (and leaves |*endpoint_url_out| invalid)
42 // if no endpoint was found.
43 bool FindEndpointForOriginAndGroup(const url::Origin& origin,
44 const std::string& group,
45 GURL* endpoint_url_out);
46
47 // Adds |endpoint| to the set of pending endpoints, preventing it from being
48 // chosen for a second parallel delivery attempt.
49 void SetEndpointPending(const GURL& endpoint);
50
51 // Removes |endpoint| from the set of pending endpoints.
52 void ClearEndpointPending(const GURL& endpoint);
53
54 // Informs the BackoffEntry for |endpoint| of a successful or not (according
55 // to |succeeded|) request.
56 void InformOfEndpointRequest(const GURL& endpoint, bool succeeded);
57
58 private:
59 base::TickClock* clock_;
60 const ReportingCache* cache_;
61 const BackoffEntry::Policy* backoff_policy_;
62
63 std::set<GURL> pending_endpoints_;
64 std::map<GURL, std::unique_ptr<net::BackoffEntry>> endpoint_backoff_;
shivanisha 2017/03/20 19:06:51 if there is no ordering needed, can we use unorder
Julia Tuttle 2017/03/21 21:43:03 Can't; GURL doesn't have a hash.
65
66 DISALLOW_COPY_AND_ASSIGN(ReportingEndpointManager);
67 };
68
69 } // namespace net
70
71 #endif // NET_REPORTING_REPORTING_ENDPOINT_MANAGER_H_
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | net/reporting/reporting_endpoint_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698