| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/metrics/metrics_memory_details.h" | 18 #include "chrome/browser/metrics/metrics_memory_details.h" |
| 19 #include "components/metrics/metrics_service_client.h" | 19 #include "components/metrics/metrics_service_client.h" |
| 20 #include "components/metrics/profiler/tracking_synchronizer_observer.h" | 20 #include "components/metrics/profiler/tracking_synchronizer_observer.h" |
| 21 #include "components/omnibox/browser/omnibox_event_global_tracker.h" | 21 #include "components/omnibox/browser/omnibox_event_global_tracker.h" |
| 22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 24 | 24 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient | 42 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient |
| 43 // that depends on chrome/. | 43 // that depends on chrome/. |
| 44 class ChromeMetricsServiceClient | 44 class ChromeMetricsServiceClient |
| 45 : public metrics::MetricsServiceClient, | 45 : public metrics::MetricsServiceClient, |
| 46 public metrics::TrackingSynchronizerObserver, | 46 public metrics::TrackingSynchronizerObserver, |
| 47 public content::NotificationObserver { | 47 public content::NotificationObserver { |
| 48 public: | 48 public: |
| 49 ~ChromeMetricsServiceClient() override; | 49 ~ChromeMetricsServiceClient() override; |
| 50 | 50 |
| 51 // Factory function. | 51 // Factory function. |
| 52 static scoped_ptr<ChromeMetricsServiceClient> Create( | 52 static std::unique_ptr<ChromeMetricsServiceClient> Create( |
| 53 metrics::MetricsStateManager* state_manager, | 53 metrics::MetricsStateManager* state_manager, |
| 54 PrefService* local_state); | 54 PrefService* local_state); |
| 55 | 55 |
| 56 // Registers local state prefs used by this class. | 56 // Registers local state prefs used by this class. |
| 57 static void RegisterPrefs(PrefRegistrySimple* registry); | 57 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 58 | 58 |
| 59 // metrics::MetricsServiceClient: | 59 // metrics::MetricsServiceClient: |
| 60 metrics::MetricsService* GetMetricsService() override; | 60 metrics::MetricsService* GetMetricsService() override; |
| 61 void SetMetricsClientId(const std::string& client_id) override; | 61 void SetMetricsClientId(const std::string& client_id) override; |
| 62 void OnRecordingDisabled() override; | 62 void OnRecordingDisabled() override; |
| 63 bool IsOffTheRecordSessionActive() override; | 63 bool IsOffTheRecordSessionActive() override; |
| 64 int32_t GetProduct() override; | 64 int32_t GetProduct() override; |
| 65 std::string GetApplicationLocale() override; | 65 std::string GetApplicationLocale() override; |
| 66 bool GetBrand(std::string* brand_code) override; | 66 bool GetBrand(std::string* brand_code) override; |
| 67 metrics::SystemProfileProto::Channel GetChannel() override; | 67 metrics::SystemProfileProto::Channel GetChannel() override; |
| 68 std::string GetVersionString() override; | 68 std::string GetVersionString() override; |
| 69 void OnLogUploadComplete() override; | 69 void OnLogUploadComplete() override; |
| 70 void InitializeSystemProfileMetrics( | 70 void InitializeSystemProfileMetrics( |
| 71 const base::Closure& done_callback) override; | 71 const base::Closure& done_callback) override; |
| 72 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | 72 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; |
| 73 scoped_ptr<metrics::MetricsLogUploader> CreateUploader( | 73 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( |
| 74 const base::Callback<void(int)>& on_upload_complete) override; | 74 const base::Callback<void(int)>& on_upload_complete) override; |
| 75 base::TimeDelta GetStandardUploadInterval() override; | 75 base::TimeDelta GetStandardUploadInterval() override; |
| 76 base::string16 GetRegistryBackupKey() override; | 76 base::string16 GetRegistryBackupKey() override; |
| 77 void OnPluginLoadingError(const base::FilePath& plugin_path) override; | 77 void OnPluginLoadingError(const base::FilePath& plugin_path) override; |
| 78 bool IsReportingPolicyManaged() override; | 78 bool IsReportingPolicyManaged() override; |
| 79 EnableMetricsDefault GetDefaultOptIn() override; | 79 EnableMetricsDefault GetDefaultOptIn() override; |
| 80 bool IsUMACellularUploadLogicEnabled() override; | 80 bool IsUMACellularUploadLogicEnabled() override; |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 explicit ChromeMetricsServiceClient( | 83 explicit ChromeMetricsServiceClient( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // any previous browser processes which generated a crash dump. | 144 // any previous browser processes which generated a crash dump. |
| 145 void CountBrowserCrashDumpAttempts(); | 145 void CountBrowserCrashDumpAttempts(); |
| 146 #endif // OS_WIN | 146 #endif // OS_WIN |
| 147 | 147 |
| 148 base::ThreadChecker thread_checker_; | 148 base::ThreadChecker thread_checker_; |
| 149 | 149 |
| 150 // Weak pointer to the MetricsStateManager. | 150 // Weak pointer to the MetricsStateManager. |
| 151 metrics::MetricsStateManager* metrics_state_manager_; | 151 metrics::MetricsStateManager* metrics_state_manager_; |
| 152 | 152 |
| 153 // The MetricsService that |this| is a client of. | 153 // The MetricsService that |this| is a client of. |
| 154 scoped_ptr<metrics::MetricsService> metrics_service_; | 154 std::unique_ptr<metrics::MetricsService> metrics_service_; |
| 155 | 155 |
| 156 content::NotificationRegistrar registrar_; | 156 content::NotificationRegistrar registrar_; |
| 157 | 157 |
| 158 #if defined(OS_CHROMEOS) | 158 #if defined(OS_CHROMEOS) |
| 159 // On ChromeOS, holds a weak pointer to the ChromeOSMetricsProvider instance | 159 // On ChromeOS, holds a weak pointer to the ChromeOSMetricsProvider instance |
| 160 // that has been registered with MetricsService. On other platforms, is NULL. | 160 // that has been registered with MetricsService. On other platforms, is NULL. |
| 161 ChromeOSMetricsProvider* chromeos_metrics_provider_; | 161 ChromeOSMetricsProvider* chromeos_metrics_provider_; |
| 162 #endif | 162 #endif |
| 163 | 163 |
| 164 // Saved callback received from CollectFinalMetricsForLog(). | 164 // Saved callback received from CollectFinalMetricsForLog(). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 // Callback to determine whether or not a cellular network is currently being | 200 // Callback to determine whether or not a cellular network is currently being |
| 201 // used. | 201 // used. |
| 202 base::Callback<void(bool*)> cellular_callback_; | 202 base::Callback<void(bool*)> cellular_callback_; |
| 203 | 203 |
| 204 // Time of this object's creation. | 204 // Time of this object's creation. |
| 205 const base::TimeTicks start_time_; | 205 const base::TimeTicks start_time_; |
| 206 | 206 |
| 207 // Subscription for receiving callbacks that a URL was opened from the | 207 // Subscription for receiving callbacks that a URL was opened from the |
| 208 // omnibox. | 208 // omnibox. |
| 209 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> | 209 std::unique_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> |
| 210 omnibox_url_opened_subscription_; | 210 omnibox_url_opened_subscription_; |
| 211 | 211 |
| 212 // Whether this client has already uploaded profiler data during this session. | 212 // Whether this client has already uploaded profiler data during this session. |
| 213 // Profiler data is uploaded at most once per session. | 213 // Profiler data is uploaded at most once per session. |
| 214 bool has_uploaded_profiler_data_; | 214 bool has_uploaded_profiler_data_; |
| 215 | 215 |
| 216 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; | 216 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; |
| 217 | 217 |
| 218 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); | 218 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 221 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
| OLD | NEW |