| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file defines a set of user experience metrics data recorded by | 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. | 6 // the MetricsService. This is the unit of data that is sent to the server. |
| 7 | 7 |
| 8 #ifndef COMPONENTS_METRICS_METRICS_LOG_H_ | 8 #ifndef COMPONENTS_METRICS_METRICS_LOG_H_ |
| 9 #define COMPONENTS_METRICS_METRICS_LOG_H_ | 9 #define COMPONENTS_METRICS_METRICS_LOG_H_ |
| 10 | 10 |
| 11 #include <stdint.h> |
| 12 |
| 11 #include <string> | 13 #include <string> |
| 12 #include <vector> | 14 #include <vector> |
| 13 | 15 |
| 14 #include "base/basictypes.h" | 16 #include "base/macros.h" |
| 15 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 16 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | 18 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
| 17 | 19 |
| 18 class PrefRegistrySimple; | 20 class PrefRegistrySimple; |
| 19 class PrefService; | 21 class PrefService; |
| 20 | 22 |
| 21 namespace base { | 23 namespace base { |
| 22 class DictionaryValue; | 24 class DictionaryValue; |
| 23 class HistogramSamples; | 25 class HistogramSamples; |
| 24 } | 26 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 LogType log_type, | 58 LogType log_type, |
| 57 MetricsServiceClient* client, | 59 MetricsServiceClient* client, |
| 58 PrefService* local_state); | 60 PrefService* local_state); |
| 59 virtual ~MetricsLog(); | 61 virtual ~MetricsLog(); |
| 60 | 62 |
| 61 // Registers local state prefs used by this class. | 63 // Registers local state prefs used by this class. |
| 62 static void RegisterPrefs(PrefRegistrySimple* registry); | 64 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 63 | 65 |
| 64 // Computes the MD5 hash of the given string, and returns the first 8 bytes of | 66 // Computes the MD5 hash of the given string, and returns the first 8 bytes of |
| 65 // the hash. | 67 // the hash. |
| 66 static uint64 Hash(const std::string& value); | 68 static uint64_t Hash(const std::string& value); |
| 67 | 69 |
| 68 // Get the GMT buildtime for the current binary, expressed in seconds since | 70 // Get the GMT buildtime for the current binary, expressed in seconds since |
| 69 // January 1, 1970 GMT. | 71 // January 1, 1970 GMT. |
| 70 // The value is used to identify when a new build is run, so that previous | 72 // The value is used to identify when a new build is run, so that previous |
| 71 // reliability stats, from other builds, can be abandoned. | 73 // reliability stats, from other builds, can be abandoned. |
| 72 static int64 GetBuildTime(); | 74 static int64_t GetBuildTime(); |
| 73 | 75 |
| 74 // Convenience function to return the current time at a resolution in seconds. | 76 // Convenience function to return the current time at a resolution in seconds. |
| 75 // This wraps base::TimeTicks, and hence provides an abstract time that is | 77 // This wraps base::TimeTicks, and hence provides an abstract time that is |
| 76 // always incrementing for use in measuring time durations. | 78 // always incrementing for use in measuring time durations. |
| 77 static int64 GetCurrentTime(); | 79 static int64_t GetCurrentTime(); |
| 78 | 80 |
| 79 // Records a user-initiated action. | 81 // Records a user-initiated action. |
| 80 void RecordUserAction(const std::string& key); | 82 void RecordUserAction(const std::string& key); |
| 81 | 83 |
| 82 // Record any changes in a given histogram for transmission. | 84 // Record any changes in a given histogram for transmission. |
| 83 void RecordHistogramDelta(const std::string& histogram_name, | 85 void RecordHistogramDelta(const std::string& histogram_name, |
| 84 const base::HistogramSamples& snapshot); | 86 const base::HistogramSamples& snapshot); |
| 85 | 87 |
| 86 // Records the current operating environment, including metrics provided by | 88 // Records the current operating environment, including metrics provided by |
| 87 // the specified set of |metrics_providers|. Takes the list of installed | 89 // the specified set of |metrics_providers|. Takes the list of installed |
| 88 // plugins, Google Update statistics, and synthetic trial IDs as parameters | 90 // plugins, Google Update statistics, and synthetic trial IDs as parameters |
| 89 // because those can't be obtained synchronously from the UI thread. | 91 // because those can't be obtained synchronously from the UI thread. |
| 90 // A synthetic trial is one that is set up dynamically by code in Chrome. For | 92 // A synthetic trial is one that is set up dynamically by code in Chrome. For |
| 91 // example, a pref may be mapped to a synthetic trial such that the group | 93 // example, a pref may be mapped to a synthetic trial such that the group |
| 92 // is determined by the pref value. | 94 // is determined by the pref value. |
| 93 void RecordEnvironment( | 95 void RecordEnvironment( |
| 94 const std::vector<MetricsProvider*>& metrics_providers, | 96 const std::vector<MetricsProvider*>& metrics_providers, |
| 95 const std::vector<variations::ActiveGroupId>& synthetic_trials, | 97 const std::vector<variations::ActiveGroupId>& synthetic_trials, |
| 96 int64 install_date, | 98 int64_t install_date, |
| 97 int64 metrics_reporting_enabled_date); | 99 int64_t metrics_reporting_enabled_date); |
| 98 | 100 |
| 99 // Loads the environment proto that was saved by the last RecordEnvironment() | 101 // Loads the environment proto that was saved by the last RecordEnvironment() |
| 100 // call from prefs and clears the pref value. Returns true on success or false | 102 // call from prefs and clears the pref value. Returns true on success or false |
| 101 // if there was no saved environment in prefs or it could not be decoded. | 103 // if there was no saved environment in prefs or it could not be decoded. |
| 102 bool LoadSavedEnvironmentFromPrefs(); | 104 bool LoadSavedEnvironmentFromPrefs(); |
| 103 | 105 |
| 104 // Writes application stability metrics, including stability metrics provided | 106 // Writes application stability metrics, including stability metrics provided |
| 105 // by the specified set of |metrics_providers|. The system profile portion of | 107 // by the specified set of |metrics_providers|. The system profile portion of |
| 106 // the log must have already been filled in by a call to RecordEnvironment() | 108 // the log must have already been filled in by a call to RecordEnvironment() |
| 107 // or LoadSavedEnvironmentFromPrefs(). | 109 // or LoadSavedEnvironmentFromPrefs(). |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 const base::TimeTicks creation_time_; | 194 const base::TimeTicks creation_time_; |
| 193 | 195 |
| 194 PrefService* local_state_; | 196 PrefService* local_state_; |
| 195 | 197 |
| 196 DISALLOW_COPY_AND_ASSIGN(MetricsLog); | 198 DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
| 197 }; | 199 }; |
| 198 | 200 |
| 199 } // namespace metrics | 201 } // namespace metrics |
| 200 | 202 |
| 201 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ | 203 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ |
| OLD | NEW |