Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: ios/chrome/browser/metrics/ios_chrome_metrics_service_client.mm

Issue 2615433002: Remove ChromeBrowserProvider::IsOffTheRecordSessionActive(). (Closed)
Patch Set: Address comment. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_client.h" 5 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "components/variations/variations_associated_data.h" 44 #include "components/variations/variations_associated_data.h"
45 #include "components/version_info/version_info.h" 45 #include "components/version_info/version_info.h"
46 #include "ios/chrome/browser/application_context.h" 46 #include "ios/chrome/browser/application_context.h"
47 #include "ios/chrome/browser/chrome_paths.h" 47 #include "ios/chrome/browser/chrome_paths.h"
48 #include "ios/chrome/browser/google/google_brand.h" 48 #include "ios/chrome/browser/google/google_brand.h"
49 #include "ios/chrome/browser/metrics/ios_chrome_stability_metrics_provider.h" 49 #include "ios/chrome/browser/metrics/ios_chrome_stability_metrics_provider.h"
50 #include "ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider.h" 50 #include "ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider.h"
51 #include "ios/chrome/browser/signin/ios_chrome_signin_status_metrics_provider_de legate.h" 51 #include "ios/chrome/browser/signin/ios_chrome_signin_status_metrics_provider_de legate.h"
52 #include "ios/chrome/browser/sync/ios_chrome_sync_client.h" 52 #include "ios/chrome/browser/sync/ios_chrome_sync_client.h"
53 #include "ios/chrome/browser/tab_parenting_global_observer.h" 53 #include "ios/chrome/browser/tab_parenting_global_observer.h"
54 #include "ios/chrome/browser/ui/browser_otr_state.h" 54 #include "ios/chrome/browser/ui/browser_list_ios.h"
55 #include "ios/chrome/common/channel_info.h" 55 #include "ios/chrome/common/channel_info.h"
56 #include "ios/web/public/web_thread.h" 56 #include "ios/web/public/web_thread.h"
57 57
58 IOSChromeMetricsServiceClient::IOSChromeMetricsServiceClient( 58 IOSChromeMetricsServiceClient::IOSChromeMetricsServiceClient(
59 metrics::MetricsStateManager* state_manager) 59 metrics::MetricsStateManager* state_manager)
60 : metrics_state_manager_(state_manager), 60 : metrics_state_manager_(state_manager),
61 stability_metrics_provider_(nullptr), 61 stability_metrics_provider_(nullptr),
62 profiler_metrics_provider_(nullptr), 62 profiler_metrics_provider_(nullptr),
63 drive_metrics_provider_(nullptr), 63 drive_metrics_provider_(nullptr),
64 start_time_(base::TimeTicks::Now()), 64 start_time_(base::TimeTicks::Now()),
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 metrics::TrackingSynchronizer::FetchProfilerDataAsynchronously( 145 metrics::TrackingSynchronizer::FetchProfilerDataAsynchronously(
146 weak_ptr_factory_.GetWeakPtr()); 146 weak_ptr_factory_.GetWeakPtr());
147 } else { 147 } else {
148 CollectFinalHistograms(); 148 CollectFinalHistograms();
149 } 149 }
150 } 150 }
151 151
152 std::unique_ptr<metrics::MetricsLogUploader> 152 std::unique_ptr<metrics::MetricsLogUploader>
153 IOSChromeMetricsServiceClient::CreateUploader( 153 IOSChromeMetricsServiceClient::CreateUploader(
154 const base::Callback<void(int)>& on_upload_complete) { 154 const base::Callback<void(int)>& on_upload_complete) {
155 return std::unique_ptr<metrics::MetricsLogUploader>( 155 return base::MakeUnique<metrics::NetMetricsLogUploader>(
156 new metrics::NetMetricsLogUploader( 156 GetApplicationContext()->GetSystemURLRequestContext(),
157 GetApplicationContext()->GetSystemURLRequestContext(), 157 metrics::kDefaultMetricsServerUrl, metrics::kDefaultMetricsMimeType,
158 metrics::kDefaultMetricsServerUrl, metrics::kDefaultMetricsMimeType, 158 on_upload_complete);
159 on_upload_complete));
160 } 159 }
161 160
162 base::TimeDelta IOSChromeMetricsServiceClient::GetStandardUploadInterval() { 161 base::TimeDelta IOSChromeMetricsServiceClient::GetStandardUploadInterval() {
163 return metrics::GetUploadInterval(); 162 return metrics::GetUploadInterval();
164 } 163 }
165 164
166 base::string16 IOSChromeMetricsServiceClient::GetRegistryBackupKey() { 165 base::string16 IOSChromeMetricsServiceClient::GetRegistryBackupKey() {
167 return base::string16(); 166 return base::string16();
168 } 167 }
169 168
170 void IOSChromeMetricsServiceClient::OnRendererProcessCrash() { 169 void IOSChromeMetricsServiceClient::OnRendererProcessCrash() {
171 stability_metrics_provider_->LogRendererCrash(); 170 stability_metrics_provider_->LogRendererCrash();
172 } 171 }
173 172
174 void IOSChromeMetricsServiceClient::WebStateDidStartLoading( 173 void IOSChromeMetricsServiceClient::WebStateDidStartLoading(
175 web::WebState* web_state) { 174 web::WebState* web_state) {
176 metrics_service_->OnApplicationNotIdle(); 175 metrics_service_->OnApplicationNotIdle();
177 } 176 }
178 177
179 void IOSChromeMetricsServiceClient::WebStateDidStopLoading( 178 void IOSChromeMetricsServiceClient::WebStateDidStopLoading(
180 web::WebState* web_state) { 179 web::WebState* web_state) {
181 metrics_service_->OnApplicationNotIdle(); 180 metrics_service_->OnApplicationNotIdle();
182 } 181 }
183 182
184 void IOSChromeMetricsServiceClient::Initialize() { 183 void IOSChromeMetricsServiceClient::Initialize() {
185 metrics_service_.reset(new metrics::MetricsService( 184 metrics_service_ = base::MakeUnique<metrics::MetricsService>(
186 metrics_state_manager_, this, GetApplicationContext()->GetLocalState())); 185 metrics_state_manager_, this, GetApplicationContext()->GetLocalState());
187 186
188 // Register metrics providers. 187 // Register metrics providers.
189 metrics_service_->RegisterMetricsProvider( 188 metrics_service_->RegisterMetricsProvider(
190 std::unique_ptr<metrics::MetricsProvider>( 189 base::MakeUnique<metrics::NetworkMetricsProvider>(
191 new metrics::NetworkMetricsProvider( 190 web::WebThread::GetBlockingPool()));
192 web::WebThread::GetBlockingPool())));
193 191
194 // Currently, we configure OmniboxMetricsProvider to not log events to UMA 192 // Currently, we configure OmniboxMetricsProvider to not log events to UMA
195 // if there is a single incognito session visible. In the future, it may 193 // if there is a single incognito session visible. In the future, it may
196 // be worth revisiting this to still log events from non-incognito sessions. 194 // be worth revisiting this to still log events from non-incognito sessions.
197 metrics_service_->RegisterMetricsProvider( 195 metrics_service_->RegisterMetricsProvider(
198 std::unique_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider( 196 base::MakeUnique<OmniboxMetricsProvider>(
199 base::Bind(&::IsOffTheRecordSessionActive)))); 197 base::Bind(&BrowserListIOS::IsOffTheRecordSessionActive)));
200 198
201 stability_metrics_provider_ = new IOSChromeStabilityMetricsProvider( 199 {
202 GetApplicationContext()->GetLocalState()); 200 auto stability_metrics_provider =
203 metrics_service_->RegisterMetricsProvider( 201 base::MakeUnique<IOSChromeStabilityMetricsProvider>(
204 std::unique_ptr<metrics::MetricsProvider>(stability_metrics_provider_)); 202 GetApplicationContext()->GetLocalState());
203 stability_metrics_provider_ = stability_metrics_provider.get();
204 metrics_service_->RegisterMetricsProvider(
205 std::move(stability_metrics_provider));
206 }
205 207
206 metrics_service_->RegisterMetricsProvider( 208 metrics_service_->RegisterMetricsProvider(
207 std::unique_ptr<metrics::MetricsProvider>( 209 base::MakeUnique<metrics::ScreenInfoMetricsProvider>());
208 new metrics::ScreenInfoMetricsProvider));
209 210
210 drive_metrics_provider_ = new metrics::DriveMetricsProvider( 211 {
211 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE), 212 auto drive_metrics_provider =
212 ios::FILE_LOCAL_STATE); 213 base::MakeUnique<metrics::DriveMetricsProvider>(
213 metrics_service_->RegisterMetricsProvider( 214 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE),
214 std::unique_ptr<metrics::MetricsProvider>(drive_metrics_provider_)); 215 ios::FILE_LOCAL_STATE);
216 drive_metrics_provider_ = drive_metrics_provider.get();
217 metrics_service_->RegisterMetricsProvider(
218 std::move(drive_metrics_provider));
219 }
215 220
216 profiler_metrics_provider_ = new metrics::ProfilerMetricsProvider( 221 {
217 base::Bind(&metrics::IsCellularLogicEnabled)); 222 auto profiler_metrics_provider =
218 metrics_service_->RegisterMetricsProvider( 223 base::MakeUnique<metrics::ProfilerMetricsProvider>(
219 std::unique_ptr<metrics::MetricsProvider>(profiler_metrics_provider_)); 224 base::Bind(&metrics::IsCellularLogicEnabled));
225 profiler_metrics_provider_ = profiler_metrics_provider.get();
226 metrics_service_->RegisterMetricsProvider(
227 std::move(profiler_metrics_provider));
228 }
220 229
221 metrics_service_->RegisterMetricsProvider( 230 metrics_service_->RegisterMetricsProvider(
222 std::unique_ptr<metrics::MetricsProvider>( 231 base::MakeUnique<metrics::CallStackProfileMetricsProvider>());
223 new metrics::CallStackProfileMetricsProvider));
224 232
225 metrics_service_->RegisterMetricsProvider( 233 metrics_service_->RegisterMetricsProvider(
226 std::unique_ptr<metrics::MetricsProvider>( 234 base::WrapUnique(SigninStatusMetricsProvider::CreateInstance(
227 SigninStatusMetricsProvider::CreateInstance(base::WrapUnique( 235 base::MakeUnique<IOSChromeSigninStatusMetricsProviderDelegate>())));
228 new IOSChromeSigninStatusMetricsProviderDelegate))));
229 236
230 metrics_service_->RegisterMetricsProvider( 237 metrics_service_->RegisterMetricsProvider(
231 std::unique_ptr<metrics::MetricsProvider>( 238 base::MakeUnique<MobileSessionShutdownMetricsProvider>(
232 new MobileSessionShutdownMetricsProvider(metrics_service_.get()))); 239 metrics_service_.get()));
233 240
234 metrics_service_->RegisterMetricsProvider( 241 metrics_service_->RegisterMetricsProvider(
235 std::unique_ptr<metrics::MetricsProvider>( 242 base::MakeUnique<syncer::DeviceCountMetricsProvider>(
236 new syncer::DeviceCountMetricsProvider( 243 base::Bind(&IOSChromeSyncClient::GetDeviceInfoTrackers)));
237 base::Bind(&IOSChromeSyncClient::GetDeviceInfoTrackers))));
238 244
239 metrics_service_->RegisterMetricsProvider( 245 metrics_service_->RegisterMetricsProvider(
240 std::unique_ptr<metrics::MetricsProvider>( 246 base::MakeUnique<translate::TranslateRankerMetricsProvider>());
241 new translate::TranslateRankerMetricsProvider()));
242 } 247 }
243 248
244 void IOSChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() { 249 void IOSChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() {
245 finished_init_task_callback_.Run(); 250 finished_init_task_callback_.Run();
246 } 251 }
247 252
248 bool IOSChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() { 253 bool IOSChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() {
249 // Upload profiler data at most once per session. 254 // Upload profiler data at most once per session.
250 if (has_uploaded_profiler_data_) 255 if (has_uploaded_profiler_data_)
251 return false; 256 return false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 316
312 void IOSChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { 317 void IOSChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {
313 metrics_service_->OnApplicationNotIdle(); 318 metrics_service_->OnApplicationNotIdle();
314 } 319 }
315 320
316 metrics::EnableMetricsDefault 321 metrics::EnableMetricsDefault
317 IOSChromeMetricsServiceClient::GetMetricsReportingDefaultState() { 322 IOSChromeMetricsServiceClient::GetMetricsReportingDefaultState() {
318 return metrics::GetMetricsReportingDefaultState( 323 return metrics::GetMetricsReportingDefaultState(
319 GetApplicationContext()->GetLocalState()); 324 GetApplicationContext()->GetLocalState());
320 } 325 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698