blob: 5935139a58133d6e8119b08d9ab250e35254c7f8 [file] [log] [blame]
[email protected]2e4cd1a2012-01-12 08:51:031// Copyright (c) 2012 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_
[email protected]32b76ef2010-07-26 23:08:2410#pragma once
initial.commit09911bf2008-07-26 23:55:2911
[email protected]6ffdb9002011-11-15 00:09:2412#include <string>
13#include <vector>
14
initial.commit09911bf2008-07-26 23:55:2915#include "base/basictypes.h"
[email protected]e182be02012-01-27 02:35:4416#include "chrome/common/metrics/metrics_log_base.h"
initial.commit09911bf2008-07-26 23:55:2917
18struct AutocompleteLog;
initial.commit09911bf2008-07-26 23:55:2919class PrefService;
20
[email protected]f3a1c642011-07-12 19:15:0321namespace base {
22class DictionaryValue;
23}
24
[email protected]191eb3f72010-12-21 06:27:5025namespace webkit {
[email protected]191eb3f72010-12-21 06:27:5026struct WebPluginInfo;
27}
[email protected]191eb3f72010-12-21 06:27:5028
[email protected]1226abb2010-06-10 18:01:2829class MetricsLog : public MetricsLogBase {
initial.commit09911bf2008-07-26 23:55:2930 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]1df44b72012-01-19 05:20:3439 // 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.commit09911bf2008-07-26 23:55:2951 // 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]191eb3f72010-12-21 06:27:5057 void RecordEnvironment(
[email protected]91d9f3d2011-08-14 05:24:4458 const std::vector<webkit::WebPluginInfo>& plugin_list,
[email protected]f3a1c642011-07-12 19:15:0359 const base::DictionaryValue* profile_metrics);
initial.commit09911bf2008-07-26 23:55:2960
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]0b33f80b2008-12-17 21:34:3665 // 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]fe58acc22012-02-29 01:29:5868 // 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]0b33f80b2008-12-17 21:34:3673
initial.commit09911bf2008-07-26 23:55:2974 private:
[email protected]c1834a92011-01-21 18:21:0375 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData);
76
initial.commit09911bf2008-07-26 23:55:2977 // Writes application stability metrics (as part of the profile log).
78 // NOTE: Has the side-effect of clearing those counts.
[email protected]fe58acc22012-02-29 01:29:5879 void WriteStabilityElement(
80 const std::vector<webkit::WebPluginInfo>& plugin_list,
81 PrefService* pref);
initial.commit09911bf2008-07-26 23:55:2982
[email protected]147bbc0b2009-01-06 19:37:4083 // Within stability group, write plugin crash stats.
[email protected]fe58acc22012-02-29 01:29:5884 void WritePluginStabilityElements(
85 const std::vector<webkit::WebPluginInfo>& plugin_list,
86 PrefService* pref);
[email protected]147bbc0b2009-01-06 19:37:4087
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]0b33f80b2008-12-17 21:34:3692 // 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]147bbc0b2009-01-06 19:37:4095 void WriteRealtimeStabilityAttributes(PrefService* pref);
[email protected]0b33f80b2008-12-17 21:34:3696
initial.commit09911bf2008-07-26 23:55:2997 // Writes the list of installed plugins.
[email protected]191eb3f72010-12-21 06:27:5098 void WritePluginList(
[email protected]91d9f3d2011-08-14 05:24:4499 const std::vector<webkit::WebPluginInfo>& plugin_list);
initial.commit09911bf2008-07-26 23:55:29100
[email protected]147bbc0b2009-01-06 19:37:40101 // Within the profile group, write basic install info including appversion.
102 void WriteInstallElement();
103
initial.commit09911bf2008-07-26 23:55:29104 // Writes all profile metrics. This invokes WriteProfileMetrics for each key
105 // in all_profiles_metrics that starts with kProfilePrefix.
[email protected]f3a1c642011-07-12 19:15:03106 void WriteAllProfilesMetrics(
107 const base::DictionaryValue& all_profiles_metrics);
initial.commit09911bf2008-07-26 23:55:29108
109 // Writes metrics for the profile identified by key. This writes all
110 // key/value pairs in profile_metrics.
[email protected]e7b418b2010-07-30 19:47:47111 void WriteProfileMetrics(const std::string& key,
[email protected]f3a1c642011-07-12 19:15:03112 const base::DictionaryValue& profile_metrics);
initial.commit09911bf2008-07-26 23:55:29113
[email protected]4d818fee2010-06-06 13:32:27114 DISALLOW_COPY_AND_ASSIGN(MetricsLog);
initial.commit09911bf2008-07-26 23:55:29115};
116
[email protected]11f4857282009-11-13 19:56:17117#endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_