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 ReportOutcome { | |
61 // A report is submitted. This includes failed and successful uploads as | |
62 // well as uploads that never return a response. | |
63 REPORT_SUBMITTED = 0, | |
64 // A report submission failed, either because of a net error or a non-HTTP | |
65 // 200 response from the server. | |
66 REPORT_FAILED = 1, | |
67 // A report submission was successfully sent, receiving an HTTP 200 response | |
68 // from the server. | |
69 REPORT_SUCCESSFUL = 2, | |
70 // A report was dropped from the reporting queue because it was older | |
71 // than report TTL, or it was ignored because the queue was full and the | |
72 // report was older than the oldest report in the queue. Does not include | |
73 // reports that were cleared because of a SafeBrowsing preference change. | |
74 REPORT_DROPPED_OR_IGNORED = 3, | |
75 REPORT_EVENT_COUNT = 4 | |
76 }; | |
77 | |
78 // Represents a report to be sent. | 58 // Represents a report to be sent. |
79 struct Report { | 59 struct Report { |
80 int report_id; | 60 int report_id; |
81 base::Time creation_time; | 61 base::Time creation_time; |
82 std::string serialized_report; | 62 std::string serialized_report; |
83 bool is_retried; | 63 bool is_retried; |
84 Report(int report_id, | 64 Report(int report_id, |
85 base::Time creation_time, | 65 base::Time creation_time, |
86 const std::string& serialized_report) | 66 const std::string& serialized_report) |
87 : report_id(report_id), | 67 : report_id(report_id), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Current report id, starting from zero and monotonically incrementing. | 146 // Current report id, starting from zero and monotonically incrementing. |
167 int current_report_id_; | 147 int current_report_id_; |
168 | 148 |
169 std::map<int, Report> inflight_reports_; | 149 std::map<int, Report> inflight_reports_; |
170 | 150 |
171 base::WeakPtrFactory<Reporter> weak_factory_; | 151 base::WeakPtrFactory<Reporter> weak_factory_; |
172 | 152 |
173 DISALLOW_COPY_AND_ASSIGN(Reporter); | 153 DISALLOW_COPY_AND_ASSIGN(Reporter); |
174 }; | 154 }; |
175 | 155 |
176 // Public for testing. | |
177 static const char kReportEventHistogram[]; | |
178 | |
179 CertificateReportingService( | 156 CertificateReportingService( |
180 safe_browsing::SafeBrowsingService* safe_browsing_service, | 157 safe_browsing::SafeBrowsingService* safe_browsing_service, |
181 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 158 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
182 Profile* profile, | 159 Profile* profile, |
183 uint8_t server_public_key[/* 32 */], | 160 uint8_t server_public_key[/* 32 */], |
184 uint32_t server_public_key_version, | 161 uint32_t server_public_key_version, |
185 size_t max_queued_report_count, | 162 size_t max_queued_report_count, |
186 base::TimeDelta max_report_age, | 163 base::TimeDelta max_report_age, |
187 base::Clock* clock, | 164 base::Clock* clock, |
188 const base::Callback<void()>& reset_callback); | 165 const base::Callback<void()>& reset_callback); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 base::Callback<void()> reset_callback_; | 240 base::Callback<void()> reset_callback_; |
264 | 241 |
265 // Encryption parameters. | 242 // Encryption parameters. |
266 uint8_t* server_public_key_; | 243 uint8_t* server_public_key_; |
267 uint32_t server_public_key_version_; | 244 uint32_t server_public_key_version_; |
268 | 245 |
269 DISALLOW_COPY_AND_ASSIGN(CertificateReportingService); | 246 DISALLOW_COPY_AND_ASSIGN(CertificateReportingService); |
270 }; | 247 }; |
271 | 248 |
272 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ | 249 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ |
OLD | NEW |