[email protected] | 2e4cd1a | 2012-01-12 08:51:03 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
| 5 | // This file defines a set of user experience metrics data recorded by |
| 6 | // the MetricsService. This is the unit of data that is sent to the server. |
| 7 | |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 8 | #ifndef CHROME_BROWSER_METRICS_METRICS_LOG_H_ |
| 9 | #define CHROME_BROWSER_METRICS_METRICS_LOG_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 10 | #pragma once |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | |
[email protected] | 6ffdb900 | 2011-11-15 00:09:24 | [diff] [blame] | 12 | #include <string> |
| 13 | #include <vector> |
| 14 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 15 | #include "base/basictypes.h" |
[email protected] | e182be0 | 2012-01-27 02:35:44 | [diff] [blame] | 16 | #include "chrome/common/metrics/metrics_log_base.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 17 | |
| 18 | struct AutocompleteLog; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 19 | class PrefService; |
| 20 | |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 21 | namespace base { |
| 22 | class DictionaryValue; |
| 23 | } |
| 24 | |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 25 | namespace webkit { |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 26 | struct WebPluginInfo; |
| 27 | } |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 28 | |
[email protected] | 1226abb | 2010-06-10 18:01:28 | [diff] [blame] | 29 | class MetricsLog : public MetricsLogBase { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 30 | public: |
| 31 | // Creates a new metrics log |
| 32 | // client_id is the identifier for this profile on this installation |
| 33 | // session_id is an integer that's incremented on each application launch |
| 34 | MetricsLog(const std::string& client_id, int session_id); |
| 35 | virtual ~MetricsLog(); |
| 36 | |
| 37 | static void RegisterPrefs(PrefService* prefs); |
| 38 | |
[email protected] | 1df44b7 | 2012-01-19 05:20:34 | [diff] [blame] | 39 | // Get the amount of uptime in seconds since this function was last called. |
| 40 | // This updates the cumulative uptime metric for uninstall as a side effect. |
| 41 | static int64 GetIncrementalUptime(PrefService* pref); |
| 42 | |
| 43 | // Get the current version of the application as a string. |
| 44 | static std::string GetVersionString(); |
| 45 | |
| 46 | // Use |extension| in all uploaded appversions in addition to the standard |
| 47 | // version string. |
| 48 | static void set_version_extension(const std::string& extension); |
| 49 | static const std::string& version_extension(); |
| 50 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 51 | // Records the current operating environment. Takes the list of installed |
| 52 | // plugins as a parameter because that can't be obtained synchronously |
| 53 | // from the UI thread. |
| 54 | // profile_metrics, if non-null, gives a dictionary of all profile metrics |
| 55 | // that are to be recorded. Each value in profile_metrics should be a |
| 56 | // dictionary giving the metrics for the profile. |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 57 | void RecordEnvironment( |
[email protected] | 91d9f3d | 2011-08-14 05:24:44 | [diff] [blame] | 58 | const std::vector<webkit::WebPluginInfo>& plugin_list, |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 59 | const base::DictionaryValue* profile_metrics); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 60 | |
| 61 | // Records the input text, available choices, and selected entry when the |
| 62 | // user uses the Omnibox to open a URL. |
| 63 | void RecordOmniboxOpenedURL(const AutocompleteLog& log); |
| 64 | |
[email protected] | 0b33f80b | 2008-12-17 21:34:36 | [diff] [blame] | 65 | // Record recent delta for critical stability metrics. We can't wait for a |
| 66 | // restart to gather these, as that delay biases our observation away from |
| 67 | // users that run happily for a looooong time. We send increments with each |
[email protected] | fe58acc2 | 2012-02-29 01:29:58 | [diff] [blame^] | 68 | // uma log upload, just as we send histogram data. Takes the list of |
| 69 | // installed plugins as a parameter because that can't be obtained |
| 70 | // synchronously from the UI thread. |
| 71 | void RecordIncrementalStabilityElements( |
| 72 | const std::vector<webkit::WebPluginInfo>& plugin_list); |
[email protected] | 0b33f80b | 2008-12-17 21:34:36 | [diff] [blame] | 73 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 74 | private: |
[email protected] | c1834a9 | 2011-01-21 18:21:03 | [diff] [blame] | 75 | FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); |
| 76 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 77 | // Writes application stability metrics (as part of the profile log). |
| 78 | // NOTE: Has the side-effect of clearing those counts. |
[email protected] | fe58acc2 | 2012-02-29 01:29:58 | [diff] [blame^] | 79 | void WriteStabilityElement( |
| 80 | const std::vector<webkit::WebPluginInfo>& plugin_list, |
| 81 | PrefService* pref); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 82 | |
[email protected] | 147bbc0b | 2009-01-06 19:37:40 | [diff] [blame] | 83 | // Within stability group, write plugin crash stats. |
[email protected] | fe58acc2 | 2012-02-29 01:29:58 | [diff] [blame^] | 84 | void WritePluginStabilityElements( |
| 85 | const std::vector<webkit::WebPluginInfo>& plugin_list, |
| 86 | PrefService* pref); |
[email protected] | 147bbc0b | 2009-01-06 19:37:40 | [diff] [blame] | 87 | |
| 88 | // Within the stability group, write required attributes. |
| 89 | void WriteRequiredStabilityAttributes(PrefService* pref); |
| 90 | |
| 91 | // Within the stability group, write attributes that need to be updated asap |
[email protected] | 0b33f80b | 2008-12-17 21:34:36 | [diff] [blame] | 92 | // and can't be delayed until the user decides to restart chromium. |
| 93 | // Delaying these stats would bias metrics away from happy long lived |
| 94 | // chromium processes (ones that don't crash, and keep on running). |
[email protected] | 147bbc0b | 2009-01-06 19:37:40 | [diff] [blame] | 95 | void WriteRealtimeStabilityAttributes(PrefService* pref); |
[email protected] | 0b33f80b | 2008-12-17 21:34:36 | [diff] [blame] | 96 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 97 | // Writes the list of installed plugins. |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 98 | void WritePluginList( |
[email protected] | 91d9f3d | 2011-08-14 05:24:44 | [diff] [blame] | 99 | const std::vector<webkit::WebPluginInfo>& plugin_list); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 100 | |
[email protected] | 147bbc0b | 2009-01-06 19:37:40 | [diff] [blame] | 101 | // Within the profile group, write basic install info including appversion. |
| 102 | void WriteInstallElement(); |
| 103 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 104 | // Writes all profile metrics. This invokes WriteProfileMetrics for each key |
| 105 | // in all_profiles_metrics that starts with kProfilePrefix. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 106 | void WriteAllProfilesMetrics( |
| 107 | const base::DictionaryValue& all_profiles_metrics); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 108 | |
| 109 | // Writes metrics for the profile identified by key. This writes all |
| 110 | // key/value pairs in profile_metrics. |
[email protected] | e7b418b | 2010-07-30 19:47:47 | [diff] [blame] | 111 | void WriteProfileMetrics(const std::string& key, |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 112 | const base::DictionaryValue& profile_metrics); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 113 | |
[email protected] | 4d818fee | 2010-06-06 13:32:27 | [diff] [blame] | 114 | DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 115 | }; |
| 116 | |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 117 | #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ |