| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ | 5 #ifndef IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ |
| 6 #define IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ | 6 #define IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
| 18 #include "components/metrics/metrics_service_client.h" | 18 #include "components/metrics/metrics_service_client.h" |
| 19 #include "components/metrics/profiler/tracking_synchronizer_observer.h" | 19 #include "components/metrics/profiler/tracking_synchronizer_observer.h" |
| 20 #include "components/omnibox/browser/omnibox_event_global_tracker.h" | 20 #include "components/omnibox/browser/omnibox_event_global_tracker.h" |
| 21 #include "components/ukm/observers/history_delete_observer.h" | 21 #include "components/ukm/observers/history_delete_observer.h" |
| 22 #include "components/ukm/observers/sync_disable_observer.h" |
| 22 #include "ios/web/public/web_state/global_web_state_observer.h" | 23 #include "ios/web/public/web_state/global_web_state_observer.h" |
| 23 | 24 |
| 24 class IOSChromeStabilityMetricsProvider; | 25 class IOSChromeStabilityMetricsProvider; |
| 25 class PrefRegistrySimple; | 26 class PrefRegistrySimple; |
| 26 | 27 |
| 27 namespace ios { | 28 namespace ios { |
| 28 class ChromeBrowserState; | 29 class ChromeBrowserState; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace metrics { | 32 namespace metrics { |
| 32 class DriveMetricsProvider; | 33 class DriveMetricsProvider; |
| 33 class MetricsService; | 34 class MetricsService; |
| 34 class MetricsStateManager; | 35 class MetricsStateManager; |
| 35 class ProfilerMetricsProvider; | 36 class ProfilerMetricsProvider; |
| 36 } // namespace metrics | 37 } // namespace metrics |
| 37 | 38 |
| 38 namespace ukm { | 39 namespace ukm { |
| 39 class UkmService; | 40 class UkmService; |
| 40 } | 41 } |
| 41 | 42 |
| 42 // IOSChromeMetricsServiceClient provides an implementation of | 43 // IOSChromeMetricsServiceClient provides an implementation of |
| 43 // MetricsServiceClient that depends on //ios/chrome/. | 44 // MetricsServiceClient that depends on //ios/chrome/. |
| 44 class IOSChromeMetricsServiceClient | 45 class IOSChromeMetricsServiceClient |
| 45 : public metrics::MetricsServiceClient, | 46 : public metrics::MetricsServiceClient, |
| 46 public metrics::TrackingSynchronizerObserver, | 47 public metrics::TrackingSynchronizerObserver, |
| 47 public ukm::HistoryDeleteObserver, | 48 public ukm::HistoryDeleteObserver, |
| 49 public ukm::SyncDisableObserver, |
| 48 public web::GlobalWebStateObserver { | 50 public web::GlobalWebStateObserver { |
| 49 public: | 51 public: |
| 50 ~IOSChromeMetricsServiceClient() override; | 52 ~IOSChromeMetricsServiceClient() override; |
| 51 | 53 |
| 52 // Factory function. | 54 // Factory function. |
| 53 static std::unique_ptr<IOSChromeMetricsServiceClient> Create( | 55 static std::unique_ptr<IOSChromeMetricsServiceClient> Create( |
| 54 metrics::MetricsStateManager* state_manager); | 56 metrics::MetricsStateManager* state_manager); |
| 55 | 57 |
| 56 // Registers local state prefs used by this class. | 58 // Registers local state prefs used by this class. |
| 57 static void RegisterPrefs(PrefRegistrySimple* registry); | 59 static void RegisterPrefs(PrefRegistrySimple* registry); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 69 const base::Closure& done_callback) override; | 71 const base::Closure& done_callback) override; |
| 70 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | 72 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; |
| 71 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( | 73 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( |
| 72 const std::string& server_url, | 74 const std::string& server_url, |
| 73 const std::string& mime_type, | 75 const std::string& mime_type, |
| 74 const base::Callback<void(int)>& on_upload_complete) override; | 76 const base::Callback<void(int)>& on_upload_complete) override; |
| 75 base::TimeDelta GetStandardUploadInterval() override; | 77 base::TimeDelta GetStandardUploadInterval() override; |
| 76 base::string16 GetRegistryBackupKey() override; | 78 base::string16 GetRegistryBackupKey() override; |
| 77 void OnRendererProcessCrash() override; | 79 void OnRendererProcessCrash() override; |
| 78 | 80 |
| 79 // ukm::HistoryDeleteObserver | 81 // ukm::HistoryDeleteObserver: |
| 80 void OnHistoryDeleted() override; | 82 void OnHistoryDeleted() override; |
| 81 | 83 |
| 84 // ukm::SyncDisableObserver: |
| 85 void OnSyncPrefsChanged(bool must_purge) override; |
| 86 |
| 82 // web::GlobalWebStateObserver: | 87 // web::GlobalWebStateObserver: |
| 83 void WebStateDidStartLoading(web::WebState* web_state) override; | 88 void WebStateDidStartLoading(web::WebState* web_state) override; |
| 84 void WebStateDidStopLoading(web::WebState* web_state) override; | 89 void WebStateDidStopLoading(web::WebState* web_state) override; |
| 85 | 90 |
| 86 metrics::EnableMetricsDefault GetMetricsReportingDefaultState() override; | 91 metrics::EnableMetricsDefault GetMetricsReportingDefaultState() override; |
| 87 | 92 |
| 88 private: | 93 private: |
| 89 explicit IOSChromeMetricsServiceClient( | 94 explicit IOSChromeMetricsServiceClient( |
| 90 metrics::MetricsStateManager* state_manager); | 95 metrics::MetricsStateManager* state_manager); |
| 91 | 96 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 111 // Callbacks for various stages of final log info collection. Do not call | 116 // Callbacks for various stages of final log info collection. Do not call |
| 112 // these directly. | 117 // these directly. |
| 113 void CollectFinalHistograms(); | 118 void CollectFinalHistograms(); |
| 114 | 119 |
| 115 // Registers |this| as an observer for notifications which indicate that a | 120 // Registers |this| as an observer for notifications which indicate that a |
| 116 // user is performing work. This is useful to allow some features to sleep, | 121 // user is performing work. This is useful to allow some features to sleep, |
| 117 // until the machine becomes active, such as precluding UMA uploads unless | 122 // until the machine becomes active, such as precluding UMA uploads unless |
| 118 // there was recent activity. | 123 // there was recent activity. |
| 119 void RegisterForNotifications(); | 124 void RegisterForNotifications(); |
| 120 | 125 |
| 121 // Register to observe history delete events on a browser state. | 126 // Register to observe events on a browser state's services. |
| 122 void RegisterForHistoryDeletions(ios::ChromeBrowserState* browser_state); | 127 void RegisterForBrowserStateEvents(ios::ChromeBrowserState* browser_state); |
| 123 | 128 |
| 124 // Called when a tab is parented. | 129 // Called when a tab is parented. |
| 125 void OnTabParented(web::WebState* web_state); | 130 void OnTabParented(web::WebState* web_state); |
| 126 | 131 |
| 127 // Called when a URL is opened from the Omnibox. | 132 // Called when a URL is opened from the Omnibox. |
| 128 void OnURLOpenedFromOmnibox(OmniboxLog* log); | 133 void OnURLOpenedFromOmnibox(OmniboxLog* log); |
| 129 | 134 |
| 130 base::ThreadChecker thread_checker_; | 135 base::ThreadChecker thread_checker_; |
| 131 | 136 |
| 132 // Weak pointer to the MetricsStateManager. | 137 // Weak pointer to the MetricsStateManager. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Whether this client has already uploaded profiler data during this session. | 176 // Whether this client has already uploaded profiler data during this session. |
| 172 // Profiler data is uploaded at most once per session. | 177 // Profiler data is uploaded at most once per session. |
| 173 bool has_uploaded_profiler_data_; | 178 bool has_uploaded_profiler_data_; |
| 174 | 179 |
| 175 base::WeakPtrFactory<IOSChromeMetricsServiceClient> weak_ptr_factory_; | 180 base::WeakPtrFactory<IOSChromeMetricsServiceClient> weak_ptr_factory_; |
| 176 | 181 |
| 177 DISALLOW_COPY_AND_ASSIGN(IOSChromeMetricsServiceClient); | 182 DISALLOW_COPY_AND_ASSIGN(IOSChromeMetricsServiceClient); |
| 178 }; | 183 }; |
| 179 | 184 |
| 180 #endif // IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ | 185 #endif // IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ |
| OLD | NEW |