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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/BUILD.gn ('k') | net/reporting/reporting_endpoint_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_endpoint_manager.h
diff --git a/net/reporting/reporting_endpoint_manager.h b/net/reporting/reporting_endpoint_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..26206bd33d78ec5de6c1cbc8ca599bd07686ca6e
--- /dev/null
+++ b/net/reporting/reporting_endpoint_manager.h
@@ -0,0 +1,71 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_REPORTING_REPORTING_ENDPOINT_MANAGER_H_
+#define NET_REPORTING_REPORTING_ENDPOINT_MANAGER_H_
+
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+
+#include "base/macros.h"
+#include "base/time/tick_clock.h"
+#include "net/base/backoff_entry.h"
+#include "net/base/net_export.h"
+#include "url/gurl.h"
+#include "url/origin.h"
+
+namespace net {
+
+class ReportingCache;
+
+// Keeps track of which endpoints are pending (have active delivery attempts to
+// them) or in exponential backoff after one or more failures, and chooses an
+// endpoint from an endpoint group to receive reports for an origin.
+class NET_EXPORT ReportingEndpointManager {
+ public:
+ ReportingEndpointManager(base::TickClock* clock,
+ const ReportingCache* cache,
+ 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.
+ ~ReportingEndpointManager();
+
+ // Finds an endpoint configured by |origin| in group |group| that is not
+ // pending, backed-off (according to BackoffEntry), or expired.
+ //
+ // Deliberately chooses an endpoint randomly to ensure sites aren't relying on
+ // any sort of fallback ordering.
+ //
+ // Returns true and sets |*endpoint_url_out| to the endpoint URL if an
+ // endpoint was chosen; returns false (and leaves |*endpoint_url_out| invalid)
+ // if no endpoint was found.
+ bool FindEndpointForOriginAndGroup(const url::Origin& origin,
+ const std::string& group,
+ GURL* endpoint_url_out);
+
+ // Adds |endpoint| to the set of pending endpoints, preventing it from being
+ // chosen for a second parallel delivery attempt.
+ void SetEndpointPending(const GURL& endpoint);
+
+ // Removes |endpoint| from the set of pending endpoints.
+ void ClearEndpointPending(const GURL& endpoint);
+
+ // Informs the BackoffEntry for |endpoint| of a successful or not (according
+ // to |succeeded|) request.
+ void InformOfEndpointRequest(const GURL& endpoint, bool succeeded);
+
+ private:
+ base::TickClock* clock_;
+ const ReportingCache* cache_;
+ const BackoffEntry::Policy* backoff_policy_;
+
+ std::set<GURL> pending_endpoints_;
+ 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.
+
+ DISALLOW_COPY_AND_ASSIGN(ReportingEndpointManager);
+};
+
+} // namespace net
+
+#endif // NET_REPORTING_REPORTING_ENDPOINT_MANAGER_H_
« 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