| 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 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/metrics/metrics_log.h" | 22 #include "chrome/browser/metrics/metrics_log.h" |
| 23 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" | 23 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" |
| 24 #include "chrome/common/metrics/metrics_service_base.h" | 24 #include "chrome/common/metrics/metrics_service_base.h" |
| 25 #include "chrome/installer/util/google_update_settings.h" | 25 #include "chrome/installer/util/google_update_settings.h" |
| 26 #include "content/public/browser/browser_child_process_observer.h" | 26 #include "content/public/browser/browser_child_process_observer.h" |
| 27 #include "content/public/browser/notification_observer.h" | 27 #include "content/public/browser/notification_observer.h" |
| 28 #include "content/public/browser/notification_registrar.h" | 28 #include "content/public/browser/notification_registrar.h" |
| 29 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
| 30 #include "net/url_request/url_fetcher_delegate.h" | 30 #include "net/url_request/url_fetcher_delegate.h" |
| 31 | 31 |
| 32 #if defined(OS_CHROMEOS) | 32 #if defined(OS_ANDROID) |
| 33 #include "chrome/browser/android/activity_type_ids.h" |
| 34 #elif defined(OS_CHROMEOS) |
| 33 #include "chrome/browser/chromeos/external_metrics.h" | 35 #include "chrome/browser/chromeos/external_metrics.h" |
| 34 #endif | 36 #endif |
| 35 | 37 |
| 36 class MetricsReportingScheduler; | 38 class MetricsReportingScheduler; |
| 37 class PrefService; | 39 class PrefService; |
| 38 class PrefRegistrySimple; | 40 class PrefRegistrySimple; |
| 39 class Profile; | 41 class Profile; |
| 40 class TemplateURLService; | 42 class TemplateURLService; |
| 41 | 43 |
| 42 namespace base { | 44 namespace base { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider( | 169 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider( |
| 168 ReportingState reporting_state); | 170 ReportingState reporting_state); |
| 169 | 171 |
| 170 // Force the client ID to be generated. This is useful in case it's needed | 172 // Force the client ID to be generated. This is useful in case it's needed |
| 171 // before recording. | 173 // before recording. |
| 172 void ForceClientIdCreation(); | 174 void ForceClientIdCreation(); |
| 173 | 175 |
| 174 // At startup, prefs needs to be called with a list of all the pref names and | 176 // At startup, prefs needs to be called with a list of all the pref names and |
| 175 // types we'll be using. | 177 // types we'll be using. |
| 176 static void RegisterPrefs(PrefRegistrySimple* registry); | 178 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 179 #if defined(OS_ANDROID) |
| 180 static void RegisterPrefsAndroid(PrefRegistrySimple* registry); |
| 181 #endif // defined(OS_ANDROID) |
| 177 | 182 |
| 178 // Set up notifications which indicate that a user is performing work. This is | 183 // Set up notifications which indicate that a user is performing work. This is |
| 179 // useful to allow some features to sleep, until the machine becomes active, | 184 // useful to allow some features to sleep, until the machine becomes active, |
| 180 // such as precluding UMA uploads unless there was recent activity. | 185 // such as precluding UMA uploads unless there was recent activity. |
| 181 static void SetUpNotifications(content::NotificationRegistrar* registrar, | 186 static void SetUpNotifications(content::NotificationRegistrar* registrar, |
| 182 content::NotificationObserver* observer); | 187 content::NotificationObserver* observer); |
| 183 | 188 |
| 184 // Implementation of content::BrowserChildProcessObserver | 189 // Implementation of content::BrowserChildProcessObserver |
| 185 virtual void BrowserChildProcessHostConnected( | 190 virtual void BrowserChildProcessHostConnected( |
| 186 const content::ChildProcessData& data) OVERRIDE; | 191 const content::ChildProcessData& data) OVERRIDE; |
| 187 virtual void BrowserChildProcessCrashed( | 192 virtual void BrowserChildProcessCrashed( |
| 188 const content::ChildProcessData& data) OVERRIDE; | 193 const content::ChildProcessData& data) OVERRIDE; |
| 189 virtual void BrowserChildProcessInstanceCreated( | 194 virtual void BrowserChildProcessInstanceCreated( |
| 190 const content::ChildProcessData& data) OVERRIDE; | 195 const content::ChildProcessData& data) OVERRIDE; |
| 191 | 196 |
| 192 // Implementation of content::NotificationObserver | 197 // Implementation of content::NotificationObserver |
| 193 virtual void Observe(int type, | 198 virtual void Observe(int type, |
| 194 const content::NotificationSource& source, | 199 const content::NotificationSource& source, |
| 195 const content::NotificationDetails& details) OVERRIDE; | 200 const content::NotificationDetails& details) OVERRIDE; |
| 196 | 201 |
| 197 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is | 202 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is |
| 198 // reset when RecordCompletedSessionEnd is invoked. | 203 // reset when RecordCompletedSessionEnd is invoked. |
| 199 void RecordStartOfSessionEnd(); | 204 void RecordStartOfSessionEnd(); |
| 200 | 205 |
| 201 // This should be called when the application is shutting down. It records | 206 // This should be called when the application is shutting down. It records |
| 202 // that session end was successful. | 207 // that session end was successful. |
| 203 void RecordCompletedSessionEnd(); | 208 void RecordCompletedSessionEnd(); |
| 204 | 209 |
| 210 #if defined(OS_ANDROID) |
| 211 // Called to record launch and crash stats to preferences. |
| 212 void RecordAndroidStabilityPrefs(); |
| 213 |
| 214 // Called to record histograms. |
| 215 void RecordAndroidStabilityHistograms(); |
| 216 |
| 217 // Called when the Activity that the user interacts with is swapped out. |
| 218 void OnForegroundActivityChanged(ActivityTypeIds::Type type); |
| 219 #endif // defined(OS_ANDROID) |
| 220 |
| 205 #if defined(OS_ANDROID) || defined(OS_IOS) | 221 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 206 // Called when the application is going into background mode. | 222 // Called when the application is going into background mode. |
| 207 void OnAppEnterBackground(); | 223 void OnAppEnterBackground(); |
| 208 | 224 |
| 209 // Called when the application is coming out of background mode. | 225 // Called when the application is coming out of background mode. |
| 210 void OnAppEnterForeground(); | 226 void OnAppEnterForeground(); |
| 211 #else | 227 #else |
| 212 // Set the dirty flag, which will require a later call to LogCleanShutdown(). | 228 // Set the dirty flag, which will require a later call to LogCleanShutdown(). |
| 213 static void LogNeedForCleanShutdown(); | 229 static void LogNeedForCleanShutdown(); |
| 214 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 230 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return entropy_source_returned_; | 354 return entropy_source_returned_; |
| 339 } | 355 } |
| 340 | 356 |
| 341 // When we start a new version of Chromium (different from our last run), we | 357 // When we start a new version of Chromium (different from our last run), we |
| 342 // need to discard the old crash stats so that we don't attribute crashes etc. | 358 // need to discard the old crash stats so that we don't attribute crashes etc. |
| 343 // in the old version to the current version (via current logs). | 359 // in the old version to the current version (via current logs). |
| 344 // Without this, a common reason to finally start a new version is to crash | 360 // Without this, a common reason to finally start a new version is to crash |
| 345 // the old version (after an autoupdate has arrived), and so we'd bias | 361 // the old version (after an autoupdate has arrived), and so we'd bias |
| 346 // initial results towards showing crashes :-(. | 362 // initial results towards showing crashes :-(. |
| 347 static void DiscardOldStabilityStats(PrefService* local_state); | 363 static void DiscardOldStabilityStats(PrefService* local_state); |
| 364 #if defined(OS_ANDROID) |
| 365 static void DiscardOldStabilityStatsAndroid(PrefService* local_state); |
| 366 #endif // defined(OS_ANDROID) |
| 348 | 367 |
| 349 // Turns recording on or off. | 368 // Turns recording on or off. |
| 350 // DisableRecording() also forces a persistent save of logging state (if | 369 // DisableRecording() also forces a persistent save of logging state (if |
| 351 // anything has been recorded, or transmitted). | 370 // anything has been recorded, or transmitted). |
| 352 void EnableRecording(); | 371 void EnableRecording(); |
| 353 void DisableRecording(); | 372 void DisableRecording(); |
| 354 | 373 |
| 355 // If in_idle is true, sets idle_since_last_transmission to true. | 374 // If in_idle is true, sets idle_since_last_transmission to true. |
| 356 // If in_idle is false and idle_since_last_transmission_ is true, sets | 375 // If in_idle is false and idle_since_last_transmission_ is true, sets |
| 357 // idle_since_last_transmission to false and starts the timer (provided | 376 // idle_since_last_transmission to false and starts the timer (provided |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 friend class extensions::ExtensionDownloader; | 625 friend class extensions::ExtensionDownloader; |
| 607 friend class extensions::ManifestFetchData; | 626 friend class extensions::ManifestFetchData; |
| 608 | 627 |
| 609 // Returns true if prefs::kMetricsReportingEnabled is set. | 628 // Returns true if prefs::kMetricsReportingEnabled is set. |
| 610 static bool IsMetricsReportingEnabled(); | 629 static bool IsMetricsReportingEnabled(); |
| 611 | 630 |
| 612 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 631 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 613 }; | 632 }; |
| 614 | 633 |
| 615 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 634 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |