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 |
58 // Represents a report to be sent. | 78 // Represents a report to be sent. |
59 struct Report { | 79 struct Report { |
60 int report_id; | 80 int report_id; |
61 base::Time creation_time; | 81 base::Time creation_time; |
62 std::string serialized_report; | 82 std::string serialized_report; |
63 bool is_retried; | 83 bool is_retried; |
64 Report(int report_id, | 84 Report(int report_id, |
65 base::Time creation_time, | 85 base::Time creation_time, |
66 const std::string& serialized_report) | 86 const std::string& serialized_report) |
67 : report_id(report_id), | 87 : 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. | 166 // Current report id, starting from zero and monotonically incrementing. |
147 int current_report_id_; | 167 int current_report_id_; |
148 | 168 |
149 std::map<int, Report> inflight_reports_; | 169 std::map<int, Report> inflight_reports_; |
150 | 170 |
151 base::WeakPtrFactory<Reporter> weak_factory_; | 171 base::WeakPtrFactory<Reporter> weak_factory_; |
152 | 172 |
153 DISALLOW_COPY_AND_ASSIGN(Reporter); | 173 DISALLOW_COPY_AND_ASSIGN(Reporter); |
154 }; | 174 }; |
155 | 175 |
| 176 // Public for testing. |
| 177 static const char kReportEventHistogram[]; |
| 178 |
156 CertificateReportingService( | 179 CertificateReportingService( |
157 safe_browsing::SafeBrowsingService* safe_browsing_service, | 180 safe_browsing::SafeBrowsingService* safe_browsing_service, |
158 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 181 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
159 Profile* profile, | 182 Profile* profile, |
160 uint8_t server_public_key[/* 32 */], | 183 uint8_t server_public_key[/* 32 */], |
161 uint32_t server_public_key_version, | 184 uint32_t server_public_key_version, |
162 size_t max_queued_report_count, | 185 size_t max_queued_report_count, |
163 base::TimeDelta max_report_age, | 186 base::TimeDelta max_report_age, |
164 base::Clock* clock, | 187 base::Clock* clock, |
165 const base::Callback<void()>& reset_callback); | 188 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_; | 263 base::Callback<void()> reset_callback_; |
241 | 264 |
242 // Encryption parameters. | 265 // Encryption parameters. |
243 uint8_t* server_public_key_; | 266 uint8_t* server_public_key_; |
244 uint32_t server_public_key_version_; | 267 uint32_t server_public_key_version_; |
245 | 268 |
246 DISALLOW_COPY_AND_ASSIGN(CertificateReportingService); | 269 DISALLOW_COPY_AND_ASSIGN(CertificateReportingService); |
247 }; | 270 }; |
248 | 271 |
249 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ | 272 #endif // CHROME_BROWSER_SAFE_BROWSING_CERTIFICATE_REPORTING_SERVICE_H_ |
OLD | NEW |