Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: components/autofill/core/browser/autofill_metrics.h

Issue 2883563002: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fix uma_session_stats.cc Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/autofill/core/browser/autofill_client.h" 15 #include "components/autofill/core/browser/autofill_client.h"
16 #include "components/autofill/core/browser/autofill_profile.h" 16 #include "components/autofill/core/browser/autofill_profile.h"
17 #include "components/autofill/core/browser/credit_card.h" 17 #include "components/autofill/core/browser/credit_card.h"
18 #include "components/autofill/core/browser/field_types.h" 18 #include "components/autofill/core/browser/field_types.h"
19 #include "components/autofill/core/common/autofill_pref_names.h" 19 #include "components/autofill/core/common/autofill_pref_names.h"
20 #include "components/autofill/core/common/form_field_data.h" 20 #include "components/autofill/core/common/form_field_data.h"
21 #include "components/ukm/public/ukm_recorder.h"
21 22
22 namespace ukm { 23 namespace ukm {
23 class UkmService; 24 class UkmRecorder;
sebsg 2017/05/18 15:54:10 not needed anymore because of your include of ukm_
oystein (OOO til 10th of July) 2017/05/18 22:06:30 Done.
24 } // namespace ukm 25 } // namespace ukm
25 26
26 namespace internal { 27 namespace internal {
27 // Name constants are exposed here so they can be referenced from tests. 28 // Name constants are exposed here so they can be referenced from tests.
28 extern const char kUKMCardUploadDecisionEntryName[]; 29 extern const char kUKMCardUploadDecisionEntryName[];
29 extern const char kUKMCardUploadDecisionMetricName[]; 30 extern const char kUKMCardUploadDecisionMetricName[];
30 extern const char kUKMDeveloperEngagementEntryName[]; 31 extern const char kUKMDeveloperEngagementEntryName[];
31 extern const char kUKMDeveloperEngagementMetricName[]; 32 extern const char kUKMDeveloperEngagementMetricName[];
32 33
33 // Each form interaction event has a separate |UkmEntry|. 34 // Each form interaction event has a separate |UkmEntry|.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 // The converted wallet address was merged into an existing local profile. 618 // The converted wallet address was merged into an existing local profile.
618 CONVERTED_ADDRESS_MERGED, 619 CONVERTED_ADDRESS_MERGED,
619 // The converted wallet address was added as a new local profile. 620 // The converted wallet address was added as a new local profile.
620 CONVERTED_ADDRESS_ADDED, 621 CONVERTED_ADDRESS_ADDED,
621 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES 622 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES
622 }; 623 };
623 624
624 // Utility to log URL keyed form interaction events. 625 // Utility to log URL keyed form interaction events.
625 class FormInteractionsUkmLogger { 626 class FormInteractionsUkmLogger {
626 public: 627 public:
627 explicit FormInteractionsUkmLogger(ukm::UkmService* ukm_service); 628 explicit FormInteractionsUkmLogger(ukm::UkmRecorder* ukm_recorder);
628 629
629 const GURL& url() const { return url_; } 630 const GURL& url() const { return url_; }
630 631
631 void OnFormsParsed(const GURL& url); 632 void OnFormsParsed(const GURL& url);
632 void LogInteractedWithForm(bool is_for_credit_card, 633 void LogInteractedWithForm(bool is_for_credit_card,
633 size_t local_record_type_count, 634 size_t local_record_type_count,
634 size_t server_record_type_count); 635 size_t server_record_type_count);
635 void LogSuggestionsShown(); 636 void LogSuggestionsShown();
636 void LogSelectedMaskedServerCard(); 637 void LogSelectedMaskedServerCard();
637 void LogDidFillSuggestion(int record_type); 638 void LogDidFillSuggestion(int record_type);
638 void LogTextFieldDidChange(const AutofillField& field); 639 void LogTextFieldDidChange(const AutofillField& field);
639 void LogFormSubmitted(AutofillFormSubmittedState state); 640 void LogFormSubmitted(AutofillFormSubmittedState state);
640 641
641 // We initialize |url_| with the form's URL when we log the first form 642 // We initialize |url_| with the form's URL when we log the first form
642 // interaction. Later, we may update |url_| with the |source_url()| for the 643 // interaction. Later, we may update |url_| with the |source_url()| for the
643 // submitted form. 644 // submitted form.
644 void UpdateSourceURL(const GURL& url); 645 void UpdateSourceURL(const GURL& url);
645 646
646 private: 647 private:
647 bool CanLog() const; 648 bool CanLog() const;
648 int64_t MillisecondsSinceFormParsed() const; 649 int64_t MillisecondsSinceFormParsed() const;
649 void GetNewSourceID(); 650 void GetNewSourceID();
650 651
651 ukm::UkmService* ukm_service_; // Weak reference. 652 ukm::UkmRecorder* ukm_recorder_; // Weak reference.
652 int32_t source_id_ = -1; 653 ukm::SourceId source_id_ = -1;
653 GURL url_; 654 GURL url_;
654 base::TimeTicks form_parsed_timestamp_; 655 base::TimeTicks form_parsed_timestamp_;
655 }; 656 };
656 657
657 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. 658 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|.
658 static void LogCardUploadDecisionMetrics(int upload_decision_metrics); 659 static void LogCardUploadDecisionMetrics(int upload_decision_metrics);
659 static void LogCreditCardInfoBarMetric( 660 static void LogCreditCardInfoBarMetric(
660 InfoBarMetric metric, 661 InfoBarMetric metric,
661 bool is_uploading, 662 bool is_uploading,
662 int previous_save_credit_card_prompt_user_decision); 663 int previous_save_credit_card_prompt_user_decision);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 // Log how the converted wallet address was added to the local autofill 815 // Log how the converted wallet address was added to the local autofill
815 // profiles. 816 // profiles.
816 static void LogWalletAddressConversionType(WalletAddressConversionType type); 817 static void LogWalletAddressConversionType(WalletAddressConversionType type);
817 818
818 // This should be called when the user selects the Form-Not-Secure warning 819 // This should be called when the user selects the Form-Not-Secure warning
819 // suggestion to show an explanation of the warning. 820 // suggestion to show an explanation of the warning.
820 static void LogShowedHttpNotSecureExplanation(); 821 static void LogShowedHttpNotSecureExplanation();
821 822
822 // Logs the card upload decisions ukm for the specified |url|. 823 // Logs the card upload decisions ukm for the specified |url|.
823 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. 824 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|.
824 static void LogCardUploadDecisionsUkm(ukm::UkmService* ukm_service, 825 static void LogCardUploadDecisionsUkm(ukm::UkmRecorder* ukm_recorder,
825 const GURL& url, 826 const GURL& url,
826 int upload_decision_metrics); 827 int upload_decision_metrics);
827 828
828 // Logs the developer engagement ukm for the specified |url| and autofill 829 // Logs the developer engagement ukm for the specified |url| and autofill
829 // fields in the form structure. |developer_engagement_metrics| is a bitmask 830 // fields in the form structure. |developer_engagement_metrics| is a bitmask
830 // of |AutofillMetrics::DeveloperEngagementMetric|. 831 // of |AutofillMetrics::DeveloperEngagementMetric|.
831 static void LogDeveloperEngagementUkm(ukm::UkmService* ukm_service, 832 static void LogDeveloperEngagementUkm(ukm::UkmRecorder* ukm_recorder,
832 const GURL& url, 833 const GURL& url,
833 int developer_engagement_metrics); 834 int developer_engagement_metrics);
834 835
835 // Logs the the |ukm_entry_name| with the specified |url| and the specified 836 // Logs the the |ukm_entry_name| with the specified |url| and the specified
836 // |metrics|. Returns whether the ukm was sucessfully logged. 837 // |metrics|. Returns whether the ukm was sucessfully logged.
837 static bool LogUkm(ukm::UkmService* ukm_service, 838 static bool LogUkm(ukm::UkmRecorder* ukm_recorder,
838 const GURL& url, 839 const GURL& url,
839 const std::string& ukm_entry_name, 840 const std::string& ukm_entry_name,
840 const std::vector<std::pair<const char*, int>>& metrics); 841 const std::vector<std::pair<const char*, int>>& metrics);
841 842
842 // Utility to log autofill form events in the relevant histograms depending on 843 // Utility to log autofill form events in the relevant histograms depending on
843 // the presence of server and/or local data. 844 // the presence of server and/or local data.
844 class FormEventLogger { 845 class FormEventLogger {
845 public: 846 public:
846 FormEventLogger(bool is_for_credit_card, 847 FormEventLogger(bool is_for_credit_card,
847 FormInteractionsUkmLogger* form_interactions_ukm_logger); 848 FormInteractionsUkmLogger* form_interactions_ukm_logger);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 902
902 private: 903 private:
903 static const int kNumCardUploadDecisionMetrics = 12; 904 static const int kNumCardUploadDecisionMetrics = 12;
904 905
905 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); 906 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics);
906 }; 907 };
907 908
908 } // namespace autofill 909 } // namespace autofill
909 910
910 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ 911 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager_unittest.cc ('k') | components/autofill/core/browser/autofill_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698