| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 service that collects information about the user | 5 // This file defines a service that collects information about the user |
| 6 // experience in order to help improve future versions of the app. | 6 // experience in order to help improve future versions of the app. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| 9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/installer/util/google_update_settings.h" | 29 #include "chrome/installer/util/google_update_settings.h" |
| 30 #include "components/metrics/metrics_provider.h" | 30 #include "components/metrics/metrics_provider.h" |
| 31 #include "components/metrics/metrics_service_observer.h" | 31 #include "components/metrics/metrics_service_observer.h" |
| 32 #include "components/variations/active_field_trials.h" | 32 #include "components/variations/active_field_trials.h" |
| 33 #include "content/public/browser/browser_child_process_observer.h" | 33 #include "content/public/browser/browser_child_process_observer.h" |
| 34 #include "content/public/browser/notification_observer.h" | 34 #include "content/public/browser/notification_observer.h" |
| 35 #include "content/public/browser/notification_registrar.h" | 35 #include "content/public/browser/notification_registrar.h" |
| 36 #include "content/public/browser/user_metrics.h" | 36 #include "content/public/browser/user_metrics.h" |
| 37 #include "net/url_request/url_fetcher_delegate.h" | 37 #include "net/url_request/url_fetcher_delegate.h" |
| 38 | 38 |
| 39 #if defined(OS_ANDROID) | |
| 40 #include "chrome/browser/android/activity_type_ids.h" | |
| 41 #endif | |
| 42 | |
| 43 class ChromeBrowserMetricsServiceObserver; | 39 class ChromeBrowserMetricsServiceObserver; |
| 44 class MetricsReportingScheduler; | 40 class MetricsReportingScheduler; |
| 45 class PrefService; | 41 class PrefService; |
| 46 class PrefRegistrySimple; | 42 class PrefRegistrySimple; |
| 47 class Profile; | 43 class Profile; |
| 48 class TemplateURLService; | 44 class TemplateURLService; |
| 49 | 45 |
| 50 namespace { | 46 namespace { |
| 51 class CrashesDOMHandler; | 47 class CrashesDOMHandler; |
| 52 class FlashDOMHandler; | 48 class FlashDOMHandler; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // | 174 // |
| 179 // If metrics reporting is enabled, this method returns an entropy provider | 175 // If metrics reporting is enabled, this method returns an entropy provider |
| 180 // that has a high source of entropy, partially based on the client ID. | 176 // that has a high source of entropy, partially based on the client ID. |
| 181 // Otherwise, it returns an entropy provider that is based on a low entropy | 177 // Otherwise, it returns an entropy provider that is based on a low entropy |
| 182 // source. | 178 // source. |
| 183 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider(); | 179 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider(); |
| 184 | 180 |
| 185 // At startup, prefs needs to be called with a list of all the pref names and | 181 // At startup, prefs needs to be called with a list of all the pref names and |
| 186 // types we'll be using. | 182 // types we'll be using. |
| 187 static void RegisterPrefs(PrefRegistrySimple* registry); | 183 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 188 #if defined(OS_ANDROID) | |
| 189 static void RegisterPrefsAndroid(PrefRegistrySimple* registry); | |
| 190 #endif // defined(OS_ANDROID) | |
| 191 | 184 |
| 192 // Set up notifications which indicate that a user is performing work. This is | 185 // Set up notifications which indicate that a user is performing work. This is |
| 193 // useful to allow some features to sleep, until the machine becomes active, | 186 // useful to allow some features to sleep, until the machine becomes active, |
| 194 // such as precluding UMA uploads unless there was recent activity. | 187 // such as precluding UMA uploads unless there was recent activity. |
| 195 static void SetUpNotifications(content::NotificationRegistrar* registrar, | 188 static void SetUpNotifications(content::NotificationRegistrar* registrar, |
| 196 content::NotificationObserver* observer); | 189 content::NotificationObserver* observer); |
| 197 | 190 |
| 198 // Implementation of content::BrowserChildProcessObserver | 191 // Implementation of content::BrowserChildProcessObserver |
| 199 virtual void BrowserChildProcessHostConnected( | 192 virtual void BrowserChildProcessHostConnected( |
| 200 const content::ChildProcessData& data) OVERRIDE; | 193 const content::ChildProcessData& data) OVERRIDE; |
| 201 virtual void BrowserChildProcessCrashed( | 194 virtual void BrowserChildProcessCrashed( |
| 202 const content::ChildProcessData& data) OVERRIDE; | 195 const content::ChildProcessData& data) OVERRIDE; |
| 203 virtual void BrowserChildProcessInstanceCreated( | 196 virtual void BrowserChildProcessInstanceCreated( |
| 204 const content::ChildProcessData& data) OVERRIDE; | 197 const content::ChildProcessData& data) OVERRIDE; |
| 205 | 198 |
| 206 // Implementation of content::NotificationObserver | 199 // Implementation of content::NotificationObserver |
| 207 virtual void Observe(int type, | 200 virtual void Observe(int type, |
| 208 const content::NotificationSource& source, | 201 const content::NotificationSource& source, |
| 209 const content::NotificationDetails& details) OVERRIDE; | 202 const content::NotificationDetails& details) OVERRIDE; |
| 210 | 203 |
| 211 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is | 204 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is |
| 212 // reset when RecordCompletedSessionEnd is invoked. | 205 // reset when RecordCompletedSessionEnd is invoked. |
| 213 void RecordStartOfSessionEnd(); | 206 void RecordStartOfSessionEnd(); |
| 214 | 207 |
| 215 // This should be called when the application is shutting down. It records | 208 // This should be called when the application is shutting down. It records |
| 216 // that session end was successful. | 209 // that session end was successful. |
| 217 void RecordCompletedSessionEnd(); | 210 void RecordCompletedSessionEnd(); |
| 218 | 211 |
| 219 #if defined(OS_ANDROID) | |
| 220 // Called to log launch and crash stats to preferences. | |
| 221 void LogAndroidStabilityToPrefs(PrefService* pref); | |
| 222 | |
| 223 // Converts crash stats stored in the preferences into histograms. | |
| 224 void ConvertAndroidStabilityPrefsToHistograms(PrefService* pref); | |
| 225 | |
| 226 // Called when the Activity that the user interacts with is swapped out. | |
| 227 void OnForegroundActivityChanged(PrefService* pref, | |
| 228 ActivityTypeIds::Type type); | |
| 229 #endif // defined(OS_ANDROID) | |
| 230 | |
| 231 #if defined(OS_ANDROID) || defined(OS_IOS) | 212 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 232 // Called when the application is going into background mode. | 213 // Called when the application is going into background mode. |
| 233 void OnAppEnterBackground(); | 214 void OnAppEnterBackground(); |
| 234 | 215 |
| 235 // Called when the application is coming out of background mode. | 216 // Called when the application is coming out of background mode. |
| 236 void OnAppEnterForeground(); | 217 void OnAppEnterForeground(); |
| 237 #else | 218 #else |
| 238 // Set the dirty flag, which will require a later call to LogCleanShutdown(). | 219 // Set the dirty flag, which will require a later call to LogCleanShutdown(). |
| 239 static void LogNeedForCleanShutdown(); | 220 static void LogNeedForCleanShutdown(); |
| 240 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 221 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 621 |
| 641 // Registers/unregisters |observer| to receive MetricsLog notifications | 622 // Registers/unregisters |observer| to receive MetricsLog notifications |
| 642 // from metrics service. | 623 // from metrics service. |
| 643 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); | 624 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); |
| 644 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); | 625 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); |
| 645 | 626 |
| 646 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 627 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 647 }; | 628 }; |
| 648 | 629 |
| 649 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 630 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |