| 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 #include "chrome/browser/metrics/chrome_metrics_service_client.h" | 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 scoped_refptr<base::TaskRunner> task_runner = | 188 scoped_refptr<base::TaskRunner> task_runner = |
| 189 content::BrowserThread::GetBlockingPool() | 189 content::BrowserThread::GetBlockingPool() |
| 190 ->GetTaskRunnerWithShutdownBehavior( | 190 ->GetTaskRunnerWithShutdownBehavior( |
| 191 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 191 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 192 | 192 |
| 193 // Create an object to monitor files of metrics and include them in reports. | 193 // Create an object to monitor files of metrics and include them in reports. |
| 194 std::unique_ptr<metrics::FileMetricsProvider> file_metrics_provider( | 194 std::unique_ptr<metrics::FileMetricsProvider> file_metrics_provider( |
| 195 new metrics::FileMetricsProvider(task_runner, | 195 new metrics::FileMetricsProvider(task_runner, |
| 196 g_browser_process->local_state())); | 196 g_browser_process->local_state())); |
| 197 | 197 |
| 198 // Register the file holding browser metrics. | |
| 199 base::FilePath user_data_dir; | 198 base::FilePath user_data_dir; |
| 200 if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 199 if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
| 200 // Register the file holding browser metrics. |
| 201 RegisterOrRemovePreviousRunMetricsFile( | 201 RegisterOrRemovePreviousRunMetricsFile( |
| 202 metrics_reporting_enabled, user_data_dir, | 202 metrics_reporting_enabled, user_data_dir, |
| 203 ChromeMetricsServiceClient::kBrowserMetricsName, task_runner, | 203 ChromeMetricsServiceClient::kBrowserMetricsName, task_runner, |
| 204 file_metrics_provider.get()); | 204 file_metrics_provider.get()); |
| 205 } | |
| 206 | 205 |
| 207 // Read the Crashpad metrics files. | 206 // Register the Crashpad metrics files. |
| 208 base::FilePath default_user_data_dir; | |
| 209 if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir)) { | |
| 210 // Register the data from the previous run if crashpad_handler didn't exit | 207 // Register the data from the previous run if crashpad_handler didn't exit |
| 211 // cleanly. | 208 // cleanly. |
| 212 RegisterOrRemovePreviousRunMetricsFile( | 209 RegisterOrRemovePreviousRunMetricsFile( |
| 213 metrics_reporting_enabled, default_user_data_dir, | 210 metrics_reporting_enabled, user_data_dir, |
| 214 kCrashpadHistogramAllocatorName, task_runner, | 211 kCrashpadHistogramAllocatorName, task_runner, |
| 215 file_metrics_provider.get()); | 212 file_metrics_provider.get()); |
| 216 if (metrics_reporting_enabled) { | 213 if (metrics_reporting_enabled) { |
| 217 base::FilePath active_path; | 214 base::FilePath active_path; |
| 218 base::GlobalHistogramAllocator::ConstructFilePaths( | 215 base::GlobalHistogramAllocator::ConstructFilePaths( |
| 219 default_user_data_dir, kCrashpadHistogramAllocatorName, nullptr, | 216 user_data_dir, kCrashpadHistogramAllocatorName, nullptr, |
| 220 &active_path); | 217 &active_path); |
| 221 // Register data that will be populated for the current run. | 218 // Register data that will be populated for the current run. |
| 222 file_metrics_provider->RegisterSource( | 219 file_metrics_provider->RegisterSource( |
| 223 active_path, | 220 active_path, |
| 224 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, | 221 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, |
| 225 metrics::FileMetricsProvider::ASSOCIATE_CURRENT_RUN, | 222 metrics::FileMetricsProvider::ASSOCIATE_CURRENT_RUN, |
| 226 kCrashpadHistogramAllocatorName); | 223 kCrashpadHistogramAllocatorName); |
| 227 } | 224 } |
| 228 } | 225 } |
| 229 | 226 |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 } | 876 } |
| 880 } | 877 } |
| 881 | 878 |
| 882 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 879 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
| 883 metrics_service_->OnApplicationNotIdle(); | 880 metrics_service_->OnApplicationNotIdle(); |
| 884 } | 881 } |
| 885 | 882 |
| 886 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 883 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
| 887 return metrics::IsCellularLogicEnabled(); | 884 return metrics::IsCellularLogicEnabled(); |
| 888 } | 885 } |
| OLD | NEW |