| 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/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/user_metrics.h" | 20 #include "base/metrics/user_metrics.h" |
| 21 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
| 22 #include "base/process/kill.h" | 22 #include "base/process/kill.h" |
| 23 #include "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "chrome/browser/metrics/metrics_log.h" | 25 #include "chrome/browser/metrics/metrics_log.h" |
| 26 #include "chrome/browser/metrics/metrics_service_observer.h" | 26 #include "chrome/browser/metrics/metrics_service_observer.h" |
| 27 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" | 27 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" |
| 28 #include "chrome/common/metrics/metrics_service_base.h" | 28 #include "chrome/common/metrics/metrics_service_base.h" |
| 29 #include "chrome/installer/util/google_update_settings.h" | 29 #include "chrome/installer/util/google_update_settings.h" |
| 30 #include "components/variations/active_field_trials.h" |
| 30 #include "content/public/browser/browser_child_process_observer.h" | 31 #include "content/public/browser/browser_child_process_observer.h" |
| 31 #include "content/public/browser/notification_observer.h" | 32 #include "content/public/browser/notification_observer.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
| 34 #include "net/url_request/url_fetcher_delegate.h" | 35 #include "net/url_request/url_fetcher_delegate.h" |
| 35 | 36 |
| 36 #if defined(OS_ANDROID) | 37 #if defined(OS_ANDROID) |
| 37 #include "chrome/browser/android/activity_type_ids.h" | 38 #include "chrome/browser/android/activity_type_ids.h" |
| 38 #elif defined(OS_CHROMEOS) | 39 #elif defined(OS_CHROMEOS) |
| 39 #include "chrome/browser/chromeos/external_metrics.h" | 40 #include "chrome/browser/chromeos/external_metrics.h" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 class ChromeBrowserMetricsServiceObserver; | 43 class ChromeBrowserMetricsServiceObserver; |
| 43 class MetricsReportingScheduler; | 44 class MetricsReportingScheduler; |
| 44 class PrefService; | 45 class PrefService; |
| 45 class PrefRegistrySimple; | 46 class PrefRegistrySimple; |
| 46 class Profile; | 47 class Profile; |
| 47 class TemplateURLService; | 48 class TemplateURLService; |
| 48 | 49 |
| 49 namespace { | 50 namespace { |
| 50 class CrashesDOMHandler; | 51 class CrashesDOMHandler; |
| 51 class FlashDOMHandler; | 52 class FlashDOMHandler; |
| 52 } | 53 } |
| 53 | 54 |
| 54 namespace base { | 55 namespace base { |
| 55 class DictionaryValue; | 56 class DictionaryValue; |
| 56 class MessageLoopProxy; | 57 class MessageLoopProxy; |
| 57 } | 58 } |
| 58 | 59 |
| 59 namespace chrome_variations { | 60 namespace variations { |
| 60 struct ActiveGroupId; | 61 struct ActiveGroupId; |
| 61 } | 62 } |
| 62 | 63 |
| 63 namespace content { | 64 namespace content { |
| 64 class RenderProcessHost; | 65 class RenderProcessHost; |
| 65 class WebContents; | 66 class WebContents; |
| 66 struct WebPluginInfo; | 67 struct WebPluginInfo; |
| 67 } | 68 } |
| 68 | 69 |
| 69 namespace extensions { | 70 namespace extensions { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 92 struct ProcessDataSnapshot; | 93 struct ProcessDataSnapshot; |
| 93 } | 94 } |
| 94 | 95 |
| 95 // A Field Trial and its selected group, which represent a particular | 96 // A Field Trial and its selected group, which represent a particular |
| 96 // Chrome configuration state. For example, the trial name could map to | 97 // Chrome configuration state. For example, the trial name could map to |
| 97 // a preference name, and the group name could map to a preference value. | 98 // a preference name, and the group name could map to a preference value. |
| 98 struct SyntheticTrialGroup { | 99 struct SyntheticTrialGroup { |
| 99 public: | 100 public: |
| 100 ~SyntheticTrialGroup(); | 101 ~SyntheticTrialGroup(); |
| 101 | 102 |
| 102 chrome_variations::ActiveGroupId id; | 103 variations::ActiveGroupId id; |
| 103 base::TimeTicks start_time; | 104 base::TimeTicks start_time; |
| 104 | 105 |
| 105 private: | 106 private: |
| 106 friend class MetricsService; | 107 friend class MetricsService; |
| 107 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); | 108 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); |
| 108 | 109 |
| 109 // This constructor is private specifically so as to control which code is | 110 // This constructor is private specifically so as to control which code is |
| 110 // able to access it. New code that wishes to use it should be added as a | 111 // able to access it. New code that wishes to use it should be added as a |
| 111 // friend class. | 112 // friend class. |
| 112 SyntheticTrialGroup(uint32 trial, uint32 group); | 113 SyntheticTrialGroup(uint32 trial, uint32 group); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // Sets the value of the specified path in prefs and schedules a save. | 475 // Sets the value of the specified path in prefs and schedules a save. |
| 475 void RecordBooleanPrefValue(const char* path, bool value); | 476 void RecordBooleanPrefValue(const char* path, bool value); |
| 476 | 477 |
| 477 // Returns true if process of type |type| should be counted as a plugin | 478 // Returns true if process of type |type| should be counted as a plugin |
| 478 // process, and false otherwise. | 479 // process, and false otherwise. |
| 479 static bool IsPluginProcess(int process_type); | 480 static bool IsPluginProcess(int process_type); |
| 480 | 481 |
| 481 // Returns a list of synthetic field trials that were active for the entire | 482 // Returns a list of synthetic field trials that were active for the entire |
| 482 // duration of the current log. | 483 // duration of the current log. |
| 483 void GetCurrentSyntheticFieldTrials( | 484 void GetCurrentSyntheticFieldTrials( |
| 484 std::vector<chrome_variations::ActiveGroupId>* synthetic_trials); | 485 std::vector<variations::ActiveGroupId>* synthetic_trials); |
| 485 | 486 |
| 486 // Used to manage various metrics reporting state prefs, such as client id, | 487 // Used to manage various metrics reporting state prefs, such as client id, |
| 487 // low entropy source and whether metrics reporting is enabled. Weak pointer. | 488 // low entropy source and whether metrics reporting is enabled. Weak pointer. |
| 488 metrics::MetricsStateManager* state_manager_; | 489 metrics::MetricsStateManager* state_manager_; |
| 489 | 490 |
| 490 base::ActionCallback action_callback_; | 491 base::ActionCallback action_callback_; |
| 491 | 492 |
| 492 content::NotificationRegistrar registrar_; | 493 content::NotificationRegistrar registrar_; |
| 493 | 494 |
| 494 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time. | 495 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 641 |
| 641 // Registers/unregisters |observer| to receive MetricsLog notifications | 642 // Registers/unregisters |observer| to receive MetricsLog notifications |
| 642 // from metrics service. | 643 // from metrics service. |
| 643 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); | 644 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); |
| 644 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); | 645 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); |
| 645 | 646 |
| 646 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 647 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 647 }; | 648 }; |
| 648 | 649 |
| 649 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 650 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |