Chromium Code Reviews| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/scoped_vector.h" | |
| 18 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 19 #include "base/metrics/field_trial.h" | 20 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/user_metrics.h" | 21 #include "base/metrics/user_metrics.h" |
| 21 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 22 #include "base/process/kill.h" | 23 #include "base/process/kill.h" |
| 23 #include "base/threading/thread_checker.h" | 24 #include "base/threading/thread_checker.h" |
| 24 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 25 #include "chrome/browser/metrics/metrics_log.h" | 26 #include "chrome/browser/metrics/metrics_log.h" |
| 26 #include "chrome/browser/metrics/metrics_service_observer.h" | 27 #include "chrome/browser/metrics/metrics_service_observer.h" |
| 27 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" | 28 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" |
| 28 #include "chrome/common/metrics/metrics_service_base.h" | 29 #include "chrome/common/metrics/metrics_service_base.h" |
| 29 #include "chrome/installer/util/google_update_settings.h" | 30 #include "chrome/installer/util/google_update_settings.h" |
| 31 #include "components/metrics/metrics_data_provider.h" | |
|
Ilya Sherman
2014/05/19 14:45:00
nit: Can this be forward-declared?
Alexei Svitkine (slow)
2014/05/19 15:23:02
Doesn't look like it:
../../base/stl_util.h:44:5:
| |
| 30 #include "content/public/browser/browser_child_process_observer.h" | 32 #include "content/public/browser/browser_child_process_observer.h" |
| 31 #include "content/public/browser/notification_observer.h" | 33 #include "content/public/browser/notification_observer.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 34 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/user_metrics.h" | 35 #include "content/public/browser/user_metrics.h" |
| 34 #include "net/url_request/url_fetcher_delegate.h" | 36 #include "net/url_request/url_fetcher_delegate.h" |
| 35 | 37 |
| 36 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
| 37 #include "chrome/browser/android/activity_type_ids.h" | 39 #include "chrome/browser/android/activity_type_ids.h" |
| 38 #elif defined(OS_CHROMEOS) | 40 #elif defined(OS_CHROMEOS) |
| 39 #include "chrome/browser/chromeos/external_metrics.h" | 41 #include "chrome/browser/chromeos/external_metrics.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 // Registers a field trial name and group to be used to annotate a UMA report | 277 // Registers a field trial name and group to be used to annotate a UMA report |
| 276 // with a particular Chrome configuration state. A UMA report will be | 278 // with a particular Chrome configuration state. A UMA report will be |
| 277 // annotated with this trial group if and only if all events in the report | 279 // annotated with this trial group if and only if all events in the report |
| 278 // were created after the trial is registered. Only one group name may be | 280 // were created after the trial is registered. Only one group name may be |
| 279 // registered at a time for a given trial_name. Only the last group name that | 281 // registered at a time for a given trial_name. Only the last group name that |
| 280 // is registered for a given trial name will be recorded. The values passed | 282 // is registered for a given trial name will be recorded. The values passed |
| 281 // in must not correspond to any real field trial in the code. | 283 // in must not correspond to any real field trial in the code. |
| 282 // To use this method, SyntheticTrialGroup should friend your class. | 284 // To use this method, SyntheticTrialGroup should friend your class. |
| 283 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group); | 285 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group); |
| 284 | 286 |
| 287 // Register the specified |provider| to provide additional metrics into the | |
| 288 // UMA log. Should be called during MetricsService initialization only. | |
| 289 void RegisterDataProvider(scoped_ptr<metrics::MetricsDataProvider> provider); | |
| 290 | |
| 285 // Check if this install was cloned or imaged from another machine. If a | 291 // Check if this install was cloned or imaged from another machine. If a |
| 286 // clone is detected, reset the client id and low entropy source. This | 292 // clone is detected, reset the client id and low entropy source. This |
| 287 // should not be called more than once. | 293 // should not be called more than once. |
| 288 void CheckForClonedInstall(); | 294 void CheckForClonedInstall(); |
| 289 | 295 |
| 290 private: | 296 private: |
| 291 // The MetricsService has a lifecycle that is stored as a state. | 297 // The MetricsService has a lifecycle that is stored as a state. |
| 292 // See metrics_service.cc for description of this lifecycle. | 298 // See metrics_service.cc for description of this lifecycle. |
| 293 enum State { | 299 enum State { |
| 294 INITIALIZED, // Constructor was called. | 300 INITIALIZED, // Constructor was called. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 | 486 |
| 481 // Returns a list of synthetic field trials that were active for the entire | 487 // Returns a list of synthetic field trials that were active for the entire |
| 482 // duration of the current log. | 488 // duration of the current log. |
| 483 void GetCurrentSyntheticFieldTrials( | 489 void GetCurrentSyntheticFieldTrials( |
| 484 std::vector<chrome_variations::ActiveGroupId>* synthetic_trials); | 490 std::vector<chrome_variations::ActiveGroupId>* synthetic_trials); |
| 485 | 491 |
| 486 // Used to manage various metrics reporting state prefs, such as client id, | 492 // Used to manage various metrics reporting state prefs, such as client id, |
| 487 // low entropy source and whether metrics reporting is enabled. Weak pointer. | 493 // low entropy source and whether metrics reporting is enabled. Weak pointer. |
| 488 metrics::MetricsStateManager* state_manager_; | 494 metrics::MetricsStateManager* state_manager_; |
| 489 | 495 |
| 496 // Additional metrics data providers that have been registered. | |
|
Ilya Sherman
2014/05/19 14:45:00
nit: Additional over what? I'd probably just omit
Alexei Svitkine (slow)
2014/05/19 15:23:02
Done.
| |
| 497 ScopedVector<metrics::MetricsDataProvider> data_providers_; | |
| 498 | |
| 490 base::ActionCallback action_callback_; | 499 base::ActionCallback action_callback_; |
| 491 | 500 |
| 492 content::NotificationRegistrar registrar_; | 501 content::NotificationRegistrar registrar_; |
| 493 | 502 |
| 494 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time. | 503 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time. |
| 495 // This prevents multiple resets within the same Chrome session. | 504 // This prevents multiple resets within the same Chrome session. |
| 496 bool metrics_ids_reset_check_performed_; | 505 bool metrics_ids_reset_check_performed_; |
| 497 | 506 |
| 498 // Indicate whether recording and reporting are currently happening. | 507 // Indicate whether recording and reporting are currently happening. |
| 499 // These should not be set directly, but by calling SetRecording and | 508 // These should not be set directly, but by calling SetRecording and |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 | 649 |
| 641 // Registers/unregisters |observer| to receive MetricsLog notifications | 650 // Registers/unregisters |observer| to receive MetricsLog notifications |
| 642 // from metrics service. | 651 // from metrics service. |
| 643 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); | 652 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); |
| 644 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); | 653 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); |
| 645 | 654 |
| 646 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 655 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 647 }; | 656 }; |
| 648 | 657 |
| 649 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 658 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |