OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 // available at all times, and it should know when SafeBrowsing shuts down. It | 48 // available at all times, and it should know when SafeBrowsing shuts down. It |
49 // does this by subscribing to SafeBrowsingService shut downs when it's | 49 // does this by subscribing to SafeBrowsingService shut downs when it's |
50 // created. When SafeBrowsingService shuts down, CertificateReportingService | 50 // created. When SafeBrowsingService shuts down, CertificateReportingService |
51 // also shuts down. | 51 // also shuts down. |
52 // | 52 // |
53 // This class also observes SafeBrowsing preference changes to enable/disable | 53 // This class also observes SafeBrowsing preference changes to enable/disable |
54 // reporting. It does this by subscribing to changes in SafeBrowsing and | 54 // reporting. It does this by subscribing to changes in SafeBrowsing and |
55 // extended reporting preferences. | 55 // extended reporting preferences. |
56 class CertificateReportingService : public KeyedService { | 56 class CertificateReportingService : public KeyedService { |
57 public: | 57 public: |
58 // Events for UMA. Do not rename or remove values, add new values to the end. | |
59 // Public for testing. | |
60 enum UMAEvent { | |
Jialiu Lin
2017/05/05 00:25:43
nit: how about "ReportOutcome"? "UMAEvent" sounds
estark
2017/05/05 16:21:13
+1
meacer
2017/05/05 19:24:19
Done.
| |
61 // A report is submitted. This includes failed and successful uploads as | |
62 // well as uploads that never return a response. | |
63 REPORT_SUBMITTED, | |
estark
2017/05/05 16:21:13
Not sure but I think you're supposed to explicitly
meacer
2017/05/05 19:24:19
Done.
| |
64 // A report submission failed. | |
65 REPORT_FAILED, | |
66 // A report submission was successful. | |
estark
2017/05/05 16:21:13
nit: perhaps define successful (HTTP 200 status co
meacer
2017/05/05 19:24:19
Done.
| |
67 REPORT_SUCCESSFUL, | |
68 // A report was dropped from the reporting queue because it was older | |
69 // than report TTL, or it was ignored because the queue was full and the | |
70 // report was older than the oldest report in the queue. Does not include | |
71 // reports that were cleared because of a SafeBrowsing preference change. | |
72 REPORT_DROPPED_OR_IGNORED, | |
73 REPORT_EVENT_COUNT | |
74 }; | |
75 | |
58 // Represents a report to be sent. | 76 // Represents a report to be sent. |
59 struct Report { | 77 struct Report { |
60 int report_id; | 78 int report_id; |
61 base::Time creation_time; | 79 base::Time creation_time; |
62 std::string serialized_report; | 80 std::string serialized_report; |
63 bool is_retried; | 81 bool is_retried; |
64 Report(int report_id, | 82 Report(int report_id, |
65 base::Time creation_time, | 83 base::Time creation_time, |
66 const std::string& serialized_report) | 84 const std::string& serialized_report) |
67 : report_id(report_id), | 85 : report_id(report_id), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 // Current report id, starting from zero and monotonically incrementing. | 164 // Current report id, starting from zero and monotonically incrementing. |
147 int current_report_id_; | 165 int current_report_id_; |
148 | 166 |
149 std::map<int, Report> inflight_reports_; | 167 std::map<int, Report> inflight_reports_; |
150 | 168 |
151 base::WeakPtrFactory<Reporter> weak_factory_; | 169 base::WeakPtrFactory<Reporter> weak_factory_; |
152 | 170 |
153 DISALLOW_COPY_AND_ASSIGN(Reporter); | 171 DISALLOW_COPY_AND_ASSIGN(Reporter); |
154 }; | 172 }; |
155 | 173 |
174 static const char kReportEventHistogram[]; | |
estark
2017/05/05 16:21:13
nit: also "Public for testing"
meacer
2017/05/05 19:24:19
Done.
| |
175 | |
156 CertificateReportingService( | 176 CertificateReportingService( |
157 safe_browsing::SafeBrowsingService* safe_browsing_service, | 177 safe_browsing::SafeBrowsingService* safe_browsing_service, |
158 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 178 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
159 Profile* profile, | 179 Profile* profile, |
160 uint8_t server_public_key[/* 32 */], | 180 uint8_t server_public_key[/* 32 */], |
161 uint32_t server_public_key_version, | 181 uint32_t server_public_key_version, |
162 size_t max_queued_report_count, | 182 size_t max_queued_report_count, |
163 base::TimeDelta max_report_age, | 183 base::TimeDelta max_report_age, |
164 base::Clock* clock, | 184 base::Clock* clock, |
165 const base::Callback<void()>& reset_callback); | 185 const base::Callback<void()>& reset_callback); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 base::Callback<void()> reset_callback_; | 260 base::Callback<void()> reset_callback_; |
241 | 261 |
242 // Encryption parameters. | 262 // Encryption parameters. |
243 uint8_t* server_public_key_; | 263 uint8_t* server_public_key_; |
244 uint32_t server_public_key_version_; | 264 uint32_t server_public_key_version_; |
245 | 265 |
246 DISALLOW_COPY_AND_ASSIGN(CertificateReportingService); | 266 DISALLOW_COPY_AND_ASSIGN(CertificateReportingService); |
247 }; | 267 }; |
248 | 268 |
249 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ | 269 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ |
OLD | NEW |