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

Side by Side Diff: components/reporting/core/browser/reporting_manager.h

Issue 2249213002: [OBSOLETE] Reporting: Initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ProfileImplIOData Created 4 years, 2 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
Randy Smith (Not in Mondays) 2016/10/21 20:15:11 Attaching a top-level comment at a random location
Julia Tuttle 2016/11/02 20:44:39 These need to happen before we turn it on: rudimen
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 COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_MANAGER_H_
6 #define COMPONENTS_REPORTING_CORE_BROWSER_REPORTING_MANAGER_H_
7
8 #include <map>
9 #include <unordered_set>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h"
15 #include "base/values.h"
16 #include "components/reporting/core/browser/reporting_cache.h"
17 #include "components/reporting/core/browser/reporting_client.h"
18 #include "components/reporting/core/browser/reporting_endpoint.h"
19 #include "components/reporting/core/browser/reporting_report.h"
20 #include "components/reporting/core/browser/reporting_uploader.h"
21 #include "components/reporting/core/common/reporting_export.h"
22 #include "net/base/backoff_entry.h"
23 #include "url/gurl.h"
24
25 namespace reporting {
26
27 struct ReportingDelivery {};
28
29 class REPORTING_EXPORT ReportingManager {
30 public:
31 ReportingManager(std::unique_ptr<ReportingUploader> uploader,
32 const base::Callback<bool(const GURL&)>& is_origin_secure);
33 ~ReportingManager();
34
35 // Section 4.1
36 void QueueReport(std::unique_ptr<ReportingReport> report);
37
38 // Section 3.2
39 void ProcessHeader(const GURL& origin, const std::string& header_value);
40
41 // Section 4.3 step 4.1.
42 void SendReports();
43
44 const ReportingCache& GetReportingCacheForTesting() const { return cache_; }
45
46 private:
47 // Section 3.3
48 struct EndpointTuple {
49 GURL url;
50 bool subdomains;
51 base::TimeDelta ttl;
52 std::string group;
53
54 // Section 3.3, step 3.3.
55 static bool FromDictionary(const base::DictionaryValue& dictionary,
56 EndpointTuple* tuple_out,
57 std::string* error_out);
58 static std::vector<EndpointTuple> FromHeader(
59 const std::string& header,
60 const base::Callback<bool(const GURL&)>& is_origin_secure,
61 std::vector<std::string>* errors_out);
62
63 std::string ToString() const;
64 };
65
66 // Context for Section 4.3 step 4, for convenience.
67 struct Delivery {
68 Delivery(
69 const std::unique_ptr<ReportingEndpoint>& endpoint,
70 const std::vector<const std::unique_ptr<ReportingReport>*>& reports);
71 ~Delivery();
72
73 const std::unique_ptr<ReportingEndpoint>& endpoint;
74 std::vector<const std::unique_ptr<ReportingReport>*> reports;
75 };
76
77 // Section 3.2, step 5.1-4
78 void ProcessEndpoint(const GURL& origin, const EndpointTuple& tuple);
79
80 // Section 4.2
81 bool DoesEndpointMatchReport(const ReportingEndpoint& endpoint,
82 const ReportingReport& report);
83
84 // Section 4.3 step 4.2.
85 void OnDeliveryAttemptComplete(const std::unique_ptr<Delivery>& delivery,
86 ReportingUploader::Outcome outcome);
87
88 // Section 4.4 steps 1-2.
89 std::string SerializeReports(
90 const std::vector<const std::unique_ptr<ReportingReport>*>& reports);
91
92 // Section 5.2
93 void CollectGarbage();
94
95 base::Callback<bool(const GURL&)> is_origin_secure_;
96 std::unique_ptr<base::TickClock> clock_;
97 net::BackoffEntry::Policy backoff_policy_;
98 ReportingCache cache_;
99 std::unique_ptr<ReportingUploader> uploader_;
100 };
101
102 } // namespace reporting
103
104 #endif // COMPONENTS_REPORTING_REPORTING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698