OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 class ProfilerMetricsProvider; | 38 class ProfilerMetricsProvider; |
39 } | 39 } |
40 | 40 |
41 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient | 41 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient |
42 // that depends on chrome/. | 42 // that depends on chrome/. |
43 class ChromeMetricsServiceClient | 43 class ChromeMetricsServiceClient |
44 : public metrics::MetricsServiceClient, | 44 : public metrics::MetricsServiceClient, |
45 public metrics::TrackingSynchronizerObserver, | 45 public metrics::TrackingSynchronizerObserver, |
46 public content::NotificationObserver { | 46 public content::NotificationObserver { |
47 public: | 47 public: |
48 virtual ~ChromeMetricsServiceClient(); | 48 ~ChromeMetricsServiceClient() override; |
49 | 49 |
50 // Factory function. | 50 // Factory function. |
51 static scoped_ptr<ChromeMetricsServiceClient> Create( | 51 static scoped_ptr<ChromeMetricsServiceClient> Create( |
52 metrics::MetricsStateManager* state_manager, | 52 metrics::MetricsStateManager* state_manager, |
53 PrefService* local_state); | 53 PrefService* local_state); |
54 | 54 |
55 // Registers local state prefs used by this class. | 55 // Registers local state prefs used by this class. |
56 static void RegisterPrefs(PrefRegistrySimple* registry); | 56 static void RegisterPrefs(PrefRegistrySimple* registry); |
57 | 57 |
58 // metrics::MetricsServiceClient: | 58 // metrics::MetricsServiceClient: |
59 virtual void SetMetricsClientId(const std::string& client_id) override; | 59 void SetMetricsClientId(const std::string& client_id) override; |
60 virtual bool IsOffTheRecordSessionActive() override; | 60 bool IsOffTheRecordSessionActive() override; |
61 virtual int32 GetProduct() override; | 61 int32 GetProduct() override; |
62 virtual std::string GetApplicationLocale() override; | 62 std::string GetApplicationLocale() override; |
63 virtual bool GetBrand(std::string* brand_code) override; | 63 bool GetBrand(std::string* brand_code) override; |
64 virtual metrics::SystemProfileProto::Channel GetChannel() override; | 64 metrics::SystemProfileProto::Channel GetChannel() override; |
65 virtual std::string GetVersionString() override; | 65 std::string GetVersionString() override; |
66 virtual void OnLogUploadComplete() override; | 66 void OnLogUploadComplete() override; |
67 virtual void StartGatheringMetrics( | 67 void StartGatheringMetrics(const base::Closure& done_callback) override; |
68 const base::Closure& done_callback) override; | 68 void CollectFinalMetrics(const base::Closure& done_callback) override; |
69 virtual void CollectFinalMetrics(const base::Closure& done_callback) | 69 scoped_ptr<metrics::MetricsLogUploader> CreateUploader( |
70 override; | |
71 virtual scoped_ptr<metrics::MetricsLogUploader> CreateUploader( | |
72 const std::string& server_url, | 70 const std::string& server_url, |
73 const std::string& mime_type, | 71 const std::string& mime_type, |
74 const base::Callback<void(int)>& on_upload_complete) override; | 72 const base::Callback<void(int)>& on_upload_complete) override; |
75 virtual base::string16 GetRegistryBackupKey() override; | 73 base::string16 GetRegistryBackupKey() override; |
76 | 74 |
77 metrics::MetricsService* metrics_service() { return metrics_service_.get(); } | 75 metrics::MetricsService* metrics_service() { return metrics_service_.get(); } |
78 | 76 |
79 void LogPluginLoadingError(const base::FilePath& plugin_path); | 77 void LogPluginLoadingError(const base::FilePath& plugin_path); |
80 | 78 |
81 private: | 79 private: |
82 explicit ChromeMetricsServiceClient( | 80 explicit ChromeMetricsServiceClient( |
83 metrics::MetricsStateManager* state_manager); | 81 metrics::MetricsStateManager* state_manager); |
84 | 82 |
85 // Completes the two-phase initialization of ChromeMetricsServiceClient. | 83 // Completes the two-phase initialization of ChromeMetricsServiceClient. |
86 void Initialize(); | 84 void Initialize(); |
87 | 85 |
88 // Callback that continues the init task by loading plugin information. | 86 // Callback that continues the init task by loading plugin information. |
89 void OnInitTaskGotHardwareClass(); | 87 void OnInitTaskGotHardwareClass(); |
90 | 88 |
91 // Called after the Plugin init task has been completed that continues the | 89 // Called after the Plugin init task has been completed that continues the |
92 // init task by launching a task to gather Google Update statistics. | 90 // init task by launching a task to gather Google Update statistics. |
93 void OnInitTaskGotPluginInfo(); | 91 void OnInitTaskGotPluginInfo(); |
94 | 92 |
95 // Called after GoogleUpdate init task has been completed that continues the | 93 // Called after GoogleUpdate init task has been completed that continues the |
96 // init task by loading profiler data. | 94 // init task by loading profiler data. |
97 void OnInitTaskGotGoogleUpdateData(); | 95 void OnInitTaskGotGoogleUpdateData(); |
98 | 96 |
99 // TrackingSynchronizerObserver: | 97 // TrackingSynchronizerObserver: |
100 virtual void ReceivedProfilerData( | 98 void ReceivedProfilerData( |
101 const tracked_objects::ProcessDataSnapshot& process_data, | 99 const tracked_objects::ProcessDataSnapshot& process_data, |
102 int process_type) override; | 100 int process_type) override; |
103 virtual void FinishedReceivingProfilerData() override; | 101 void FinishedReceivingProfilerData() override; |
104 | 102 |
105 // Callbacks for various stages of final log info collection. Do not call | 103 // Callbacks for various stages of final log info collection. Do not call |
106 // these directly. | 104 // these directly. |
107 void OnMemoryDetailCollectionDone(); | 105 void OnMemoryDetailCollectionDone(); |
108 void OnHistogramSynchronizationDone(); | 106 void OnHistogramSynchronizationDone(); |
109 | 107 |
110 // Records metrics about the switches present on the command line. | 108 // Records metrics about the switches present on the command line. |
111 void RecordCommandLineMetrics(); | 109 void RecordCommandLineMetrics(); |
112 | 110 |
113 // Registers |this| as an observer for notifications which indicate that a | 111 // Registers |this| as an observer for notifications which indicate that a |
114 // user is performing work. This is useful to allow some features to sleep, | 112 // user is performing work. This is useful to allow some features to sleep, |
115 // until the machine becomes active, such as precluding UMA uploads unless | 113 // until the machine becomes active, such as precluding UMA uploads unless |
116 // there was recent activity. | 114 // there was recent activity. |
117 void RegisterForNotifications(); | 115 void RegisterForNotifications(); |
118 | 116 |
119 // content::NotificationObserver: | 117 // content::NotificationObserver: |
120 virtual void Observe(int type, | 118 void Observe(int type, |
121 const content::NotificationSource& source, | 119 const content::NotificationSource& source, |
122 const content::NotificationDetails& details) override; | 120 const content::NotificationDetails& details) override; |
123 | 121 |
124 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
125 // Counts (and removes) the browser crash dump attempt signals left behind by | 123 // Counts (and removes) the browser crash dump attempt signals left behind by |
126 // any previous browser processes which generated a crash dump. | 124 // any previous browser processes which generated a crash dump. |
127 void CountBrowserCrashDumpAttempts(); | 125 void CountBrowserCrashDumpAttempts(); |
128 #endif // OS_WIN | 126 #endif // OS_WIN |
129 | 127 |
130 base::ThreadChecker thread_checker_; | 128 base::ThreadChecker thread_checker_; |
131 | 129 |
132 // Weak pointer to the MetricsStateManager. | 130 // Weak pointer to the MetricsStateManager. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // The MemoryGrowthTracker instance that tracks memory usage growth in | 172 // The MemoryGrowthTracker instance that tracks memory usage growth in |
175 // MemoryDetails. | 173 // MemoryDetails. |
176 MemoryGrowthTracker memory_growth_tracker_; | 174 MemoryGrowthTracker memory_growth_tracker_; |
177 | 175 |
178 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; | 176 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; |
179 | 177 |
180 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); | 178 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); |
181 }; | 179 }; |
182 | 180 |
183 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 181 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
OLD | NEW |