[email protected] | e612d76 | 2010-03-31 04:32:30 | [diff] [blame] | 1 | // Copyright (c) 2010 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_ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 10 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | #include "base/basictypes.h" |
[email protected] | 1226abb | 2010-06-10 18:01:28 | [diff] [blame^] | 12 | #include "chrome/common/metrics_helpers.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | #include "chrome/common/page_transition_types.h" |
[email protected] | e612d76 | 2010-03-31 04:32:30 | [diff] [blame] | 14 | #include "webkit/glue/plugins/webplugininfo.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 15 | |
| 16 | struct AutocompleteLog; |
| 17 | class DictionaryValue; |
[email protected] | 46072d4 | 2008-07-28 14:49:35 | [diff] [blame] | 18 | class GURL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 19 | class PrefService; |
| 20 | |
[email protected] | 1226abb | 2010-06-10 18:01:28 | [diff] [blame^] | 21 | class MetricsLog : public MetricsLogBase { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 22 | public: |
| 23 | // Creates a new metrics log |
| 24 | // client_id is the identifier for this profile on this installation |
| 25 | // session_id is an integer that's incremented on each application launch |
| 26 | MetricsLog(const std::string& client_id, int session_id); |
| 27 | virtual ~MetricsLog(); |
| 28 | |
| 29 | static void RegisterPrefs(PrefService* prefs); |
| 30 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | // Records the current operating environment. Takes the list of installed |
| 32 | // plugins as a parameter because that can't be obtained synchronously |
| 33 | // from the UI thread. |
| 34 | // profile_metrics, if non-null, gives a dictionary of all profile metrics |
| 35 | // that are to be recorded. Each value in profile_metrics should be a |
| 36 | // dictionary giving the metrics for the profile. |
| 37 | void RecordEnvironment(const std::vector<WebPluginInfo>& plugin_list, |
| 38 | const DictionaryValue* profile_metrics); |
| 39 | |
| 40 | // Records the input text, available choices, and selected entry when the |
| 41 | // user uses the Omnibox to open a URL. |
| 42 | void RecordOmniboxOpenedURL(const AutocompleteLog& log); |
| 43 | |
[email protected] | 0b33f80b | 2008-12-17 21:34:36 | [diff] [blame] | 44 | // Record recent delta for critical stability metrics. We can't wait for a |
| 45 | // restart to gather these, as that delay biases our observation away from |
| 46 | // users that run happily for a looooong time. We send increments with each |
| 47 | // uma log upload, just as we send histogram data. |
| 48 | void RecordIncrementalStabilityElements(); |
| 49 | |
[email protected] | 9165f74 | 2010-03-10 22:55:01 | [diff] [blame] | 50 | // Get the amount of uptime in seconds since this function was last called. |
| 51 | // This updates the cumulative uptime metric for uninstall as a side effect. |
| 52 | static int64 GetIncrementalUptime(PrefService* pref); |
| 53 | |
[email protected] | 1226abb | 2010-06-10 18:01:28 | [diff] [blame^] | 54 | // Get the current version of the application as a string. |
| 55 | static std::string GetVersionString(); |
| 56 | |
| 57 | virtual MetricsLog* AsMetricsLog() { |
| 58 | return this; |
[email protected] | 5ed7d457 | 2009-12-23 17:42:41 | [diff] [blame] | 59 | } |
[email protected] | 85ed9d4 | 2010-06-08 22:37:44 | [diff] [blame] | 60 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 61 | private: |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 62 | // Returns the date at which the current metrics client ID was created as |
| 63 | // a string containing milliseconds since the epoch, or "0" if none was found. |
| 64 | std::string GetInstallDate() const; |
| 65 | |
[email protected] | 1226abb | 2010-06-10 18:01:28 | [diff] [blame^] | 66 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 67 | // Writes application stability metrics (as part of the profile log). |
| 68 | // NOTE: Has the side-effect of clearing those counts. |
| 69 | void WriteStabilityElement(); |
| 70 | |
[email protected] | 147bbc0b | 2009-01-06 19:37:40 | [diff] [blame] | 71 | // Within stability group, write plugin crash stats. |
| 72 | void WritePluginStabilityElements(PrefService* pref); |
| 73 | |
| 74 | // Within the stability group, write required attributes. |
| 75 | void WriteRequiredStabilityAttributes(PrefService* pref); |
| 76 | |
| 77 | // Within the stability group, write attributes that need to be updated asap |
[email protected] | 0b33f80b | 2008-12-17 21:34:36 | [diff] [blame] | 78 | // and can't be delayed until the user decides to restart chromium. |
| 79 | // Delaying these stats would bias metrics away from happy long lived |
| 80 | // chromium processes (ones that don't crash, and keep on running). |
[email protected] | 147bbc0b | 2009-01-06 19:37:40 | [diff] [blame] | 81 | void WriteRealtimeStabilityAttributes(PrefService* pref); |
[email protected] | 0b33f80b | 2008-12-17 21:34:36 | [diff] [blame] | 82 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 83 | // Writes the list of installed plugins. |
| 84 | void WritePluginList(const std::vector<WebPluginInfo>& plugin_list); |
| 85 | |
[email protected] | 147bbc0b | 2009-01-06 19:37:40 | [diff] [blame] | 86 | // Within the profile group, write basic install info including appversion. |
| 87 | void WriteInstallElement(); |
| 88 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 89 | // Writes all profile metrics. This invokes WriteProfileMetrics for each key |
| 90 | // in all_profiles_metrics that starts with kProfilePrefix. |
| 91 | void WriteAllProfilesMetrics(const DictionaryValue& all_profiles_metrics); |
| 92 | |
| 93 | // Writes metrics for the profile identified by key. This writes all |
| 94 | // key/value pairs in profile_metrics. |
| 95 | void WriteProfileMetrics(const std::wstring& key, |
| 96 | const DictionaryValue& profile_metrics); |
| 97 | |
[email protected] | 4d818fee | 2010-06-06 13:32:27 | [diff] [blame] | 98 | DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 99 | }; |
| 100 | |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 101 | #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ |