| 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 #ifndef COMPONENTS_SECURITY_INTERSTITIALS_CORE_METRICS_HELPER_H_ | 5 #ifndef COMPONENTS_SECURITY_INTERSTITIALS_CORE_METRICS_HELPER_H_ |
| 6 #define COMPONENTS_SECURITY_INTERSTITIALS_CORE_METRICS_HELPER_H_ | 6 #define COMPONENTS_SECURITY_INTERSTITIALS_CORE_METRICS_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 MetricsHelper(const GURL& url, | 84 MetricsHelper(const GURL& url, |
| 85 const ReportDetails settings, | 85 const ReportDetails settings, |
| 86 history::HistoryService* history_service, | 86 history::HistoryService* history_service, |
| 87 rappor::RapporService* rappor_service); | 87 rappor::RapporService* rappor_service); |
| 88 virtual ~MetricsHelper() {} | 88 virtual ~MetricsHelper() {} |
| 89 | 89 |
| 90 // Records a user decision or interaction to the appropriate UMA metrics | 90 // Records a user decision or interaction to the appropriate UMA metrics |
| 91 // histogram and potentially in a RAPPOR metric. | 91 // histogram and potentially in a RAPPOR metric. |
| 92 void RecordUserDecision(Decision decision); | 92 void RecordUserDecision(Decision decision); |
| 93 void RecordUserInteraction(Interaction interaction); | 93 void RecordUserInteraction(Interaction interaction); |
| 94 void RecordShutdownMetrics(); |
| 95 |
| 94 // Number of times user visited this origin before. -1 means not-yet-set. | 96 // Number of times user visited this origin before. -1 means not-yet-set. |
| 95 int NumVisits(); | 97 int NumVisits(); |
| 96 | 98 |
| 97 protected: | 99 protected: |
| 98 // Subclasses should implement any embedder-specific recording logic in these | 100 // Subclasses should implement any embedder-specific recording logic in these |
| 99 // methods. They'll be invoked from RecordUserDecision/Interaction. | 101 // methods. They'll be invoked from the matching Record methods. |
| 100 virtual void RecordExtraUserDecisionMetrics(Decision decision) = 0; | 102 virtual void RecordExtraUserDecisionMetrics(Decision decision) = 0; |
| 101 virtual void RecordExtraUserInteractionMetrics(Interaction interaction) = 0; | 103 virtual void RecordExtraUserInteractionMetrics(Interaction interaction) = 0; |
| 104 virtual void RecordExtraShutdownMetrics() = 0; |
| 102 | 105 |
| 103 private: | 106 private: |
| 104 // Used to query the HistoryService to see if the URL is in history. It will | 107 // Used to query the HistoryService to see if the URL is in history. It will |
| 105 // only be invoked if the constructor received |history_service|. | 108 // only be invoked if the constructor received |history_service|. |
| 106 void OnGotHistoryCount(bool success, int num_visits, base::Time first_visit); | 109 void OnGotHistoryCount(bool success, int num_visits, base::Time first_visit); |
| 107 | 110 |
| 108 void RecordUserDecisionToMetrics(Decision decision, | 111 void RecordUserDecisionToMetrics(Decision decision, |
| 109 const std::string& histogram_name); | 112 const std::string& histogram_name); |
| 110 void RecordUserDecisionToRappor(Decision decision); | 113 void RecordUserDecisionToRappor(Decision decision); |
| 111 const GURL request_url_; | 114 const GURL request_url_; |
| 112 const ReportDetails settings_; | 115 const ReportDetails settings_; |
| 113 rappor::RapporService* rappor_service_; | 116 rappor::RapporService* rappor_service_; |
| 114 int num_visits_; | 117 int num_visits_; |
| 115 base::CancelableTaskTracker request_tracker_; | 118 base::CancelableTaskTracker request_tracker_; |
| 116 | 119 |
| 117 DISALLOW_COPY_AND_ASSIGN(MetricsHelper); | 120 DISALLOW_COPY_AND_ASSIGN(MetricsHelper); |
| 118 }; | 121 }; |
| 119 | 122 |
| 120 } // namespace security_interstitials | 123 } // namespace security_interstitials |
| 121 | 124 |
| 122 #endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_METRICS_HELPER_H_ | 125 #endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_METRICS_HELPER_H_ |
| OLD | NEW |