Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: chrome/browser/metrics/metrics_service.h

Issue 296483004: Introduce a MetricsDataProvider interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/tracking_synchronizer_observer.h" 27 #include "chrome/browser/metrics/tracking_synchronizer_observer.h"
27 #include "chrome/common/metrics/metrics_service_base.h" 28 #include "chrome/common/metrics/metrics_service_base.h"
28 #include "chrome/installer/util/google_update_settings.h" 29 #include "chrome/installer/util/google_update_settings.h"
30 #include "components/metrics/metrics_provider.h"
29 #include "components/metrics/metrics_service_observer.h" 31 #include "components/metrics/metrics_service_observer.h"
30 #include "components/variations/active_field_trials.h" 32 #include "components/variations/active_field_trials.h"
31 #include "content/public/browser/browser_child_process_observer.h" 33 #include "content/public/browser/browser_child_process_observer.h"
32 #include "content/public/browser/notification_observer.h" 34 #include "content/public/browser/notification_observer.h"
33 #include "content/public/browser/notification_registrar.h" 35 #include "content/public/browser/notification_registrar.h"
34 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
35 #include "net/url_request/url_fetcher_delegate.h" 37 #include "net/url_request/url_fetcher_delegate.h"
36 38
37 #if defined(OS_ANDROID) 39 #if defined(OS_ANDROID)
38 #include "chrome/browser/android/activity_type_ids.h" 40 #include "chrome/browser/android/activity_type_ids.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // Registers a field trial name and group to be used to annotate a UMA report 272 // Registers a field trial name and group to be used to annotate a UMA report
271 // with a particular Chrome configuration state. A UMA report will be 273 // with a particular Chrome configuration state. A UMA report will be
272 // annotated with this trial group if and only if all events in the report 274 // annotated with this trial group if and only if all events in the report
273 // were created after the trial is registered. Only one group name may be 275 // were created after the trial is registered. Only one group name may be
274 // registered at a time for a given trial_name. Only the last group name that 276 // registered at a time for a given trial_name. Only the last group name that
275 // is registered for a given trial name will be recorded. The values passed 277 // is registered for a given trial name will be recorded. The values passed
276 // in must not correspond to any real field trial in the code. 278 // in must not correspond to any real field trial in the code.
277 // To use this method, SyntheticTrialGroup should friend your class. 279 // To use this method, SyntheticTrialGroup should friend your class.
278 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group); 280 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group);
279 281
282 // Register the specified |provider| to provide additional metrics into the
283 // UMA log. Should be called during MetricsService initialization only.
284 void RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider> provider);
285
280 // Check if this install was cloned or imaged from another machine. If a 286 // Check if this install was cloned or imaged from another machine. If a
281 // clone is detected, reset the client id and low entropy source. This 287 // clone is detected, reset the client id and low entropy source. This
282 // should not be called more than once. 288 // should not be called more than once.
283 void CheckForClonedInstall( 289 void CheckForClonedInstall(
284 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 290 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
285 291
286 private: 292 private:
287 // The MetricsService has a lifecycle that is stored as a state. 293 // The MetricsService has a lifecycle that is stored as a state.
288 // See metrics_service.cc for description of this lifecycle. 294 // See metrics_service.cc for description of this lifecycle.
289 enum State { 295 enum State {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 482
477 // Returns a list of synthetic field trials that were active for the entire 483 // Returns a list of synthetic field trials that were active for the entire
478 // duration of the current log. 484 // duration of the current log.
479 void GetCurrentSyntheticFieldTrials( 485 void GetCurrentSyntheticFieldTrials(
480 std::vector<variations::ActiveGroupId>* synthetic_trials); 486 std::vector<variations::ActiveGroupId>* synthetic_trials);
481 487
482 // Used to manage various metrics reporting state prefs, such as client id, 488 // Used to manage various metrics reporting state prefs, such as client id,
483 // low entropy source and whether metrics reporting is enabled. Weak pointer. 489 // low entropy source and whether metrics reporting is enabled. Weak pointer.
484 metrics::MetricsStateManager* state_manager_; 490 metrics::MetricsStateManager* state_manager_;
485 491
492 // Registered metrics providers.
493 ScopedVector<metrics::MetricsProvider> metrics_providers_;
494
486 base::ActionCallback action_callback_; 495 base::ActionCallback action_callback_;
487 496
488 content::NotificationRegistrar registrar_; 497 content::NotificationRegistrar registrar_;
489 498
490 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time. 499 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time.
491 // This prevents multiple resets within the same Chrome session. 500 // This prevents multiple resets within the same Chrome session.
492 bool metrics_ids_reset_check_performed_; 501 bool metrics_ids_reset_check_performed_;
493 502
494 // Indicate whether recording and reporting are currently happening. 503 // Indicate whether recording and reporting are currently happening.
495 // These should not be set directly, but by calling SetRecording and 504 // These should not be set directly, but by calling SetRecording and
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 640
632 // Registers/unregisters |observer| to receive MetricsLog notifications 641 // Registers/unregisters |observer| to receive MetricsLog notifications
633 // from metrics service. 642 // from metrics service.
634 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); 643 static void AddMetricsServiceObserver(MetricsServiceObserver* observer);
635 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); 644 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer);
636 645
637 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); 646 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
638 }; 647 };
639 648
640 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 649 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log_unittest.cc ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698