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 <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 "components/metrics/metrics_service_client.h" | 17 #include "components/metrics/metrics_service_client.h" |
18 #include "components/metrics/profiler/tracking_synchronizer_observer.h" | 18 #include "components/metrics/profiler/tracking_synchronizer_observer.h" |
19 #include "components/omnibox/browser/omnibox_event_global_tracker.h" | 19 #include "components/omnibox/browser/omnibox_event_global_tracker.h" |
20 #include "ios/web/public/web_state/global_web_state_observer.h" | 20 #include "ios/web/public/web_state/global_web_state_observer.h" |
21 | 21 |
22 class IOSChromeStabilityMetricsProvider; | 22 class IOSChromeStabilityMetricsProvider; |
23 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
24 class PrefService; | 24 class PrefService; |
(...skipping 12 matching lines...) Expand all Loading... |
37 // IOSChromeMetricsServiceClient provides an implementation of | 37 // IOSChromeMetricsServiceClient provides an implementation of |
38 // MetricsServiceClient that depends on //ios/chrome/. | 38 // MetricsServiceClient that depends on //ios/chrome/. |
39 class IOSChromeMetricsServiceClient | 39 class IOSChromeMetricsServiceClient |
40 : public metrics::MetricsServiceClient, | 40 : public metrics::MetricsServiceClient, |
41 public metrics::TrackingSynchronizerObserver, | 41 public metrics::TrackingSynchronizerObserver, |
42 public web::GlobalWebStateObserver { | 42 public web::GlobalWebStateObserver { |
43 public: | 43 public: |
44 ~IOSChromeMetricsServiceClient() override; | 44 ~IOSChromeMetricsServiceClient() override; |
45 | 45 |
46 // Factory function. | 46 // Factory function. |
47 static scoped_ptr<IOSChromeMetricsServiceClient> Create( | 47 static std::unique_ptr<IOSChromeMetricsServiceClient> Create( |
48 metrics::MetricsStateManager* state_manager, | 48 metrics::MetricsStateManager* state_manager, |
49 PrefService* local_state); | 49 PrefService* local_state); |
50 | 50 |
51 // Registers local state prefs used by this class. | 51 // Registers local state prefs used by this class. |
52 static void RegisterPrefs(PrefRegistrySimple* registry); | 52 static void RegisterPrefs(PrefRegistrySimple* registry); |
53 | 53 |
54 // metrics::MetricsServiceClient: | 54 // metrics::MetricsServiceClient: |
55 metrics::MetricsService* GetMetricsService() override; | 55 metrics::MetricsService* GetMetricsService() override; |
56 void SetMetricsClientId(const std::string& client_id) override; | 56 void SetMetricsClientId(const std::string& client_id) override; |
57 void OnRecordingDisabled() override; | 57 void OnRecordingDisabled() override; |
58 bool IsOffTheRecordSessionActive() override; | 58 bool IsOffTheRecordSessionActive() override; |
59 int32_t GetProduct() override; | 59 int32_t GetProduct() override; |
60 std::string GetApplicationLocale() override; | 60 std::string GetApplicationLocale() override; |
61 bool GetBrand(std::string* brand_code) override; | 61 bool GetBrand(std::string* brand_code) override; |
62 metrics::SystemProfileProto::Channel GetChannel() override; | 62 metrics::SystemProfileProto::Channel GetChannel() override; |
63 std::string GetVersionString() override; | 63 std::string GetVersionString() override; |
64 void OnLogUploadComplete() override; | 64 void OnLogUploadComplete() override; |
65 void InitializeSystemProfileMetrics( | 65 void InitializeSystemProfileMetrics( |
66 const base::Closure& done_callback) override; | 66 const base::Closure& done_callback) override; |
67 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | 67 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; |
68 scoped_ptr<metrics::MetricsLogUploader> CreateUploader( | 68 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( |
69 const base::Callback<void(int)>& on_upload_complete) override; | 69 const base::Callback<void(int)>& on_upload_complete) override; |
70 base::TimeDelta GetStandardUploadInterval() override; | 70 base::TimeDelta GetStandardUploadInterval() override; |
71 base::string16 GetRegistryBackupKey() override; | 71 base::string16 GetRegistryBackupKey() override; |
72 void OnRendererProcessCrash() override; | 72 void OnRendererProcessCrash() override; |
73 | 73 |
74 // web::GlobalWebStateObserver: | 74 // web::GlobalWebStateObserver: |
75 void WebStateDidStartLoading(web::WebState* web_state) override; | 75 void WebStateDidStartLoading(web::WebState* web_state) override; |
76 void WebStateDidStopLoading(web::WebState* web_state) override; | 76 void WebStateDidStopLoading(web::WebState* web_state) override; |
77 | 77 |
78 private: | 78 private: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 // Called when a URL is opened from the Omnibox. | 114 // Called when a URL is opened from the Omnibox. |
115 void OnURLOpenedFromOmnibox(OmniboxLog* log); | 115 void OnURLOpenedFromOmnibox(OmniboxLog* log); |
116 | 116 |
117 base::ThreadChecker thread_checker_; | 117 base::ThreadChecker thread_checker_; |
118 | 118 |
119 // Weak pointer to the MetricsStateManager. | 119 // Weak pointer to the MetricsStateManager. |
120 metrics::MetricsStateManager* metrics_state_manager_; | 120 metrics::MetricsStateManager* metrics_state_manager_; |
121 | 121 |
122 // The MetricsService that |this| is a client of. | 122 // The MetricsService that |this| is a client of. |
123 scoped_ptr<metrics::MetricsService> metrics_service_; | 123 std::unique_ptr<metrics::MetricsService> metrics_service_; |
124 | 124 |
125 // The IOSChromeStabilityMetricsProvider instance that was registered with | 125 // The IOSChromeStabilityMetricsProvider instance that was registered with |
126 // MetricsService. Has the same lifetime as |metrics_service_|. | 126 // MetricsService. Has the same lifetime as |metrics_service_|. |
127 IOSChromeStabilityMetricsProvider* stability_metrics_provider_; | 127 IOSChromeStabilityMetricsProvider* stability_metrics_provider_; |
128 | 128 |
129 // Saved callback received from CollectFinalMetricsForLog(). | 129 // Saved callback received from CollectFinalMetricsForLog(). |
130 base::Closure collect_final_metrics_done_callback_; | 130 base::Closure collect_final_metrics_done_callback_; |
131 | 131 |
132 // The ProfilerMetricsProvider instance that was registered with | 132 // The ProfilerMetricsProvider instance that was registered with |
133 // MetricsService. Has the same lifetime as |metrics_service_|. | 133 // MetricsService. Has the same lifetime as |metrics_service_|. |
134 metrics::ProfilerMetricsProvider* profiler_metrics_provider_; | 134 metrics::ProfilerMetricsProvider* profiler_metrics_provider_; |
135 | 135 |
136 // The DriveMetricsProvider instance that was registered with MetricsService. | 136 // The DriveMetricsProvider instance that was registered with MetricsService. |
137 // Has the same lifetime as |metrics_service_|. | 137 // Has the same lifetime as |metrics_service_|. |
138 metrics::DriveMetricsProvider* drive_metrics_provider_; | 138 metrics::DriveMetricsProvider* drive_metrics_provider_; |
139 | 139 |
140 // Callback that is called when initial metrics gathering is complete. | 140 // Callback that is called when initial metrics gathering is complete. |
141 base::Closure finished_init_task_callback_; | 141 base::Closure finished_init_task_callback_; |
142 | 142 |
143 // Time of this object's creation. | 143 // Time of this object's creation. |
144 const base::TimeTicks start_time_; | 144 const base::TimeTicks start_time_; |
145 | 145 |
146 // Subscription for receiving callbacks that a tab was parented. | 146 // Subscription for receiving callbacks that a tab was parented. |
147 scoped_ptr<base::CallbackList<void(web::WebState*)>::Subscription> | 147 std::unique_ptr<base::CallbackList<void(web::WebState*)>::Subscription> |
148 tab_parented_subscription_; | 148 tab_parented_subscription_; |
149 | 149 |
150 // Subscription for receiving callbacks that a URL was opened from the | 150 // Subscription for receiving callbacks that a URL was opened from the |
151 // omnibox. | 151 // omnibox. |
152 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> | 152 std::unique_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> |
153 omnibox_url_opened_subscription_; | 153 omnibox_url_opened_subscription_; |
154 | 154 |
155 // Whether this client has already uploaded profiler data during this session. | 155 // Whether this client has already uploaded profiler data during this session. |
156 // Profiler data is uploaded at most once per session. | 156 // Profiler data is uploaded at most once per session. |
157 bool has_uploaded_profiler_data_; | 157 bool has_uploaded_profiler_data_; |
158 | 158 |
159 base::WeakPtrFactory<IOSChromeMetricsServiceClient> weak_ptr_factory_; | 159 base::WeakPtrFactory<IOSChromeMetricsServiceClient> weak_ptr_factory_; |
160 | 160 |
161 DISALLOW_COPY_AND_ASSIGN(IOSChromeMetricsServiceClient); | 161 DISALLOW_COPY_AND_ASSIGN(IOSChromeMetricsServiceClient); |
162 }; | 162 }; |
163 | 163 |
164 #endif // IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ | 164 #endif // IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ |
OLD | NEW |