blob: c7ba23f58a065ffbfe8479a4abccf3c720dbf7bc [file] [log] [blame]
[email protected]e612d762010-03-31 04:32:301// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
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]11f4857282009-11-13 19:56:178#ifndef CHROME_BROWSER_METRICS_METRICS_LOG_H_
9#define CHROME_BROWSER_METRICS_METRICS_LOG_H_
initial.commit09911bf2008-07-26 23:55:2910
initial.commit09911bf2008-07-26 23:55:2911#include "base/basictypes.h"
[email protected]1226abb2010-06-10 18:01:2812#include "chrome/common/metrics_helpers.h"
initial.commit09911bf2008-07-26 23:55:2913#include "chrome/common/page_transition_types.h"
[email protected]e612d762010-03-31 04:32:3014#include "webkit/glue/plugins/webplugininfo.h"
initial.commit09911bf2008-07-26 23:55:2915
16struct AutocompleteLog;
17class DictionaryValue;
[email protected]46072d42008-07-28 14:49:3518class GURL;
initial.commit09911bf2008-07-26 23:55:2919class PrefService;
20
[email protected]1226abb2010-06-10 18:01:2821class MetricsLog : public MetricsLogBase {
initial.commit09911bf2008-07-26 23:55:2922 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.commit09911bf2008-07-26 23:55:2931 // 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]0b33f80b2008-12-17 21:34:3644 // 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]9165f742010-03-10 22:55:0150 // 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]1226abb2010-06-10 18:01:2854 // 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]5ed7d4572009-12-23 17:42:4159 }
[email protected]85ed9d42010-06-08 22:37:4460
initial.commit09911bf2008-07-26 23:55:2961 private:
initial.commit09911bf2008-07-26 23:55:2962 // 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]1226abb2010-06-10 18:01:2866
initial.commit09911bf2008-07-26 23:55:2967 // 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]147bbc0b2009-01-06 19:37:4071 // 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]0b33f80b2008-12-17 21:34:3678 // 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]147bbc0b2009-01-06 19:37:4081 void WriteRealtimeStabilityAttributes(PrefService* pref);
[email protected]0b33f80b2008-12-17 21:34:3682
initial.commit09911bf2008-07-26 23:55:2983 // Writes the list of installed plugins.
84 void WritePluginList(const std::vector<WebPluginInfo>& plugin_list);
85
[email protected]147bbc0b2009-01-06 19:37:4086 // Within the profile group, write basic install info including appversion.
87 void WriteInstallElement();
88
initial.commit09911bf2008-07-26 23:55:2989 // 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]4d818fee2010-06-06 13:32:2798 DISALLOW_COPY_AND_ASSIGN(MetricsLog);
initial.commit09911bf2008-07-26 23:55:2999};
100
[email protected]11f4857282009-11-13 19:56:17101#endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_