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 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" | 4 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
5 | 5 |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "base/time/clock.h" | 9 #include "base/time/clock.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 error_reporter_->SendExtendedReportingReport( | 136 error_reporter_->SendExtendedReportingReport( |
137 report.serialized_report, | 137 report.serialized_report, |
138 base::Bind(&CertificateReportingService::Reporter::SuccessCallback, | 138 base::Bind(&CertificateReportingService::Reporter::SuccessCallback, |
139 weak_factory_.GetWeakPtr(), report.report_id), | 139 weak_factory_.GetWeakPtr(), report.report_id), |
140 base::Bind(&CertificateReportingService::Reporter::ErrorCallback, | 140 base::Bind(&CertificateReportingService::Reporter::ErrorCallback, |
141 weak_factory_.GetWeakPtr(), report.report_id)); | 141 weak_factory_.GetWeakPtr(), report.report_id)); |
142 } | 142 } |
143 | 143 |
144 void CertificateReportingService::Reporter::ErrorCallback(int report_id, | 144 void CertificateReportingService::Reporter::ErrorCallback(int report_id, |
145 const GURL& url, | 145 const GURL& url, |
146 int error) { | 146 int error, |
147 int response_code) { | |
147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 148 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
148 RecordUMAOnFailure(error); | 149 RecordUMAOnFailure(error); |
Nathan Parker
2017/02/07 01:33:01
How about also logging the response_code to UMA no
| |
149 if (retries_enabled_) { | 150 if (retries_enabled_) { |
150 auto it = inflight_reports_.find(report_id); | 151 auto it = inflight_reports_.find(report_id); |
151 DCHECK(it != inflight_reports_.end()); | 152 DCHECK(it != inflight_reports_.end()); |
152 retry_list_->Add(it->second); | 153 retry_list_->Add(it->second); |
153 } | 154 } |
154 CHECK_GT(inflight_reports_.erase(report_id), 0u); | 155 CHECK_GT(inflight_reports_.erase(report_id), 0u); |
155 } | 156 } |
156 | 157 |
157 void CertificateReportingService::Reporter::SuccessCallback(int report_id) { | 158 void CertificateReportingService::Reporter::SuccessCallback(int report_id, |
159 int response_code) { | |
158 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 160 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
159 CHECK_GT(inflight_reports_.erase(report_id), 0u); | 161 CHECK_GT(inflight_reports_.erase(report_id), 0u); |
160 } | 162 } |
161 | 163 |
162 CertificateReportingService::CertificateReportingService( | 164 CertificateReportingService::CertificateReportingService( |
163 safe_browsing::SafeBrowsingService* safe_browsing_service, | 165 safe_browsing::SafeBrowsingService* safe_browsing_service, |
164 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 166 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
165 Profile* profile, | 167 Profile* profile, |
166 uint8_t server_public_key[/* 32 */], | 168 uint8_t server_public_key[/* 32 */], |
167 uint32_t server_public_key_version, | 169 uint32_t server_public_key_version, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 } | 312 } |
311 | 313 |
312 void CertificateReportingService::OnPreferenceChanged() { | 314 void CertificateReportingService::OnPreferenceChanged() { |
313 safe_browsing::SafeBrowsingService* safe_browsing_service_ = | 315 safe_browsing::SafeBrowsingService* safe_browsing_service_ = |
314 g_browser_process->safe_browsing_service(); | 316 g_browser_process->safe_browsing_service(); |
315 const bool enabled = safe_browsing_service_ && | 317 const bool enabled = safe_browsing_service_ && |
316 safe_browsing_service_->enabled_by_prefs() && | 318 safe_browsing_service_->enabled_by_prefs() && |
317 safe_browsing::IsExtendedReportingEnabled(pref_service_); | 319 safe_browsing::IsExtendedReportingEnabled(pref_service_); |
318 SetEnabled(enabled); | 320 SetEnabled(enabled); |
319 } | 321 } |
OLD | NEW |