| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "components/security_interstitials/metrics_helper.h" | 5 #include "components/security_interstitials/metrics_helper.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "components/history/core/browser/history_service.h" | 8 #include "components/history/core/browser/history_service.h" |
| 9 #include "components/rappor/rappor_service.h" | 9 #include "components/rappor/rappor_service.h" |
| 10 #include "components/rappor/rappor_utils.h" | 10 #include "components/rappor/rappor_utils.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 MetricsHelper::MetricsHelper(const GURL& request_url, | 24 MetricsHelper::MetricsHelper(const GURL& request_url, |
| 25 const ReportDetails settings, | 25 const ReportDetails settings, |
| 26 history::HistoryService* history_service, | 26 history::HistoryService* history_service, |
| 27 rappor::RapporService* rappor_service) | 27 rappor::RapporService* rappor_service) |
| 28 : request_url_(request_url), | 28 : request_url_(request_url), |
| 29 settings_(settings), | 29 settings_(settings), |
| 30 rappor_service_(rappor_service), | 30 rappor_service_(rappor_service), |
| 31 num_visits_(-1) { | 31 num_visits_(-1) { |
| 32 DCHECK(!settings_.metric_prefix.empty()); | 32 DCHECK(!settings_.metric_prefix.empty()); |
| 33 if (settings_.rappor_report_type == rappor::NUM_RAPPOR_TYPES) // Default. | 33 if (settings_.rappor_report_type == rappor::NUM_RAPPOR_TYPES) // Default. |
| 34 rappor_service = nullptr; | 34 rappor_service_ = nullptr; |
| 35 DCHECK(!rappor_service || !settings_.rappor_prefix.empty()); | 35 DCHECK(!rappor_service_ || !settings_.rappor_prefix.empty()); |
| 36 if (history_service) { | 36 if (history_service) { |
| 37 history_service->GetVisibleVisitCountToHost( | 37 history_service->GetVisibleVisitCountToHost( |
| 38 request_url_, | 38 request_url_, |
| 39 base::Bind(&MetricsHelper::OnGotHistoryCount, base::Unretained(this)), | 39 base::Bind(&MetricsHelper::OnGotHistoryCount, base::Unretained(this)), |
| 40 &request_tracker_); | 40 &request_tracker_); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Directly adds to the UMA histograms, using the same properties as | 44 // Directly adds to the UMA histograms, using the same properties as |
| 45 // UMA_HISTOGRAM_ENUMERATION, because the macro doesn't allow non-constant | 45 // UMA_HISTOGRAM_ENUMERATION, because the macro doesn't allow non-constant |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 void MetricsHelper::OnGotHistoryCount(bool success, | 109 void MetricsHelper::OnGotHistoryCount(bool success, |
| 110 int num_visits, | 110 int num_visits, |
| 111 base::Time /*first_visit*/) { | 111 base::Time /*first_visit*/) { |
| 112 if (success) | 112 if (success) |
| 113 num_visits_ = num_visits; | 113 num_visits_ = num_visits; |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace security_interstitials | 116 } // namespace security_interstitials |
| OLD | NEW |