blob: 95b125218b3a3463742c6b9d0ab0b02e1713af68 [file] [log] [blame]
[email protected]6ffdb9002011-11-15 00:09:241// Copyright (c) 2011 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]1226abb2010-06-10 18:01:2816#include "chrome/common/metrics_helpers.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
initial.commit09911bf2008-07-26 23:55:2939 // Records the current operating environment. Takes the list of installed
40 // plugins as a parameter because that can't be obtained synchronously
41 // from the UI thread.
42 // profile_metrics, if non-null, gives a dictionary of all profile metrics
43 // that are to be recorded. Each value in profile_metrics should be a
44 // dictionary giving the metrics for the profile.
[email protected]191eb3f72010-12-21 06:27:5045 void RecordEnvironment(
[email protected]91d9f3d2011-08-14 05:24:4446 const std::vector<webkit::WebPluginInfo>& plugin_list,
[email protected]f3a1c642011-07-12 19:15:0347 const base::DictionaryValue* profile_metrics);
initial.commit09911bf2008-07-26 23:55:2948
49 // Records the input text, available choices, and selected entry when the
50 // user uses the Omnibox to open a URL.
51 void RecordOmniboxOpenedURL(const AutocompleteLog& log);
52
[email protected]0b33f80b2008-12-17 21:34:3653 // Record recent delta for critical stability metrics. We can't wait for a
54 // restart to gather these, as that delay biases our observation away from
55 // users that run happily for a looooong time. We send increments with each
56 // uma log upload, just as we send histogram data.
57 void RecordIncrementalStabilityElements();
58
[email protected]9165f742010-03-10 22:55:0159 // Get the amount of uptime in seconds since this function was last called.
60 // This updates the cumulative uptime metric for uninstall as a side effect.
61 static int64 GetIncrementalUptime(PrefService* pref);
62
[email protected]1226abb2010-06-10 18:01:2863 // Get the current version of the application as a string.
64 static std::string GetVersionString();
65
[email protected]dec76e802010-09-23 22:43:5366 virtual MetricsLog* AsMetricsLog();
[email protected]85ed9d42010-06-08 22:37:4467
initial.commit09911bf2008-07-26 23:55:2968 private:
[email protected]c1834a92011-01-21 18:21:0369 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData);
70
initial.commit09911bf2008-07-26 23:55:2971 // Returns the date at which the current metrics client ID was created as
72 // a string containing milliseconds since the epoch, or "0" if none was found.
73 std::string GetInstallDate() const;
74
[email protected]1226abb2010-06-10 18:01:2875
initial.commit09911bf2008-07-26 23:55:2976 // Writes application stability metrics (as part of the profile log).
77 // NOTE: Has the side-effect of clearing those counts.
[email protected]c1834a92011-01-21 18:21:0378 void WriteStabilityElement(PrefService* pref);
initial.commit09911bf2008-07-26 23:55:2979
[email protected]147bbc0b2009-01-06 19:37:4080 // Within stability group, write plugin crash stats.
81 void WritePluginStabilityElements(PrefService* pref);
82
83 // Within the stability group, write required attributes.
84 void WriteRequiredStabilityAttributes(PrefService* pref);
85
86 // Within the stability group, write attributes that need to be updated asap
[email protected]0b33f80b2008-12-17 21:34:3687 // and can't be delayed until the user decides to restart chromium.
88 // Delaying these stats would bias metrics away from happy long lived
89 // chromium processes (ones that don't crash, and keep on running).
[email protected]147bbc0b2009-01-06 19:37:4090 void WriteRealtimeStabilityAttributes(PrefService* pref);
[email protected]0b33f80b2008-12-17 21:34:3691
initial.commit09911bf2008-07-26 23:55:2992 // Writes the list of installed plugins.
[email protected]191eb3f72010-12-21 06:27:5093 void WritePluginList(
[email protected]91d9f3d2011-08-14 05:24:4494 const std::vector<webkit::WebPluginInfo>& plugin_list);
initial.commit09911bf2008-07-26 23:55:2995
[email protected]147bbc0b2009-01-06 19:37:4096 // Within the profile group, write basic install info including appversion.
97 void WriteInstallElement();
98
initial.commit09911bf2008-07-26 23:55:2999 // Writes all profile metrics. This invokes WriteProfileMetrics for each key
100 // in all_profiles_metrics that starts with kProfilePrefix.
[email protected]f3a1c642011-07-12 19:15:03101 void WriteAllProfilesMetrics(
102 const base::DictionaryValue& all_profiles_metrics);
initial.commit09911bf2008-07-26 23:55:29103
104 // Writes metrics for the profile identified by key. This writes all
105 // key/value pairs in profile_metrics.
[email protected]e7b418b2010-07-30 19:47:47106 void WriteProfileMetrics(const std::string& key,
[email protected]f3a1c642011-07-12 19:15:03107 const base::DictionaryValue& profile_metrics);
initial.commit09911bf2008-07-26 23:55:29108
[email protected]4d818fee2010-06-06 13:32:27109 DISALLOW_COPY_AND_ASSIGN(MetricsLog);
initial.commit09911bf2008-07-26 23:55:29110};
111
[email protected]11f4857282009-11-13 19:56:17112#endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_