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

Side by Side Diff: chrome/browser/metrics/chrome_metrics_service_client.cc

Issue 2344343002: Wire in postmortem report collection (Closed)
Patch Set: Address first round Created 4 years, 2 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 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 <vector> 9 #include <vector>
10 10
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 chromeos_metrics_provider_(nullptr), 242 chromeos_metrics_provider_(nullptr),
243 #endif 243 #endif
244 waiting_for_collect_final_metrics_step_(false), 244 waiting_for_collect_final_metrics_step_(false),
245 num_async_histogram_fetches_in_progress_(0), 245 num_async_histogram_fetches_in_progress_(0),
246 profiler_metrics_provider_(nullptr), 246 profiler_metrics_provider_(nullptr),
247 #if defined(ENABLE_PLUGINS) 247 #if defined(ENABLE_PLUGINS)
248 plugin_metrics_provider_(nullptr), 248 plugin_metrics_provider_(nullptr),
249 #endif 249 #endif
250 #if defined(OS_WIN) 250 #if defined(OS_WIN)
251 google_update_metrics_provider_(nullptr), 251 google_update_metrics_provider_(nullptr),
252 watcher_metrics_provider_(nullptr),
253 antivirus_metrics_provider_(nullptr),
252 #endif 254 #endif
253 drive_metrics_provider_(nullptr), 255 drive_metrics_provider_(nullptr),
254 start_time_(base::TimeTicks::Now()), 256 start_time_(base::TimeTicks::Now()),
255 has_uploaded_profiler_data_(false), 257 has_uploaded_profiler_data_(false),
256 weak_ptr_factory_(this) { 258 weak_ptr_factory_(this) {
257 DCHECK(thread_checker_.CalledOnValidThread()); 259 DCHECK(thread_checker_.CalledOnValidThread());
258 RecordCommandLineMetrics(); 260 RecordCommandLineMetrics();
259 RegisterForNotifications(); 261 RegisterForNotifications();
260 } 262 }
261 263
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 metrics_service_->RegisterMetricsProvider( 493 metrics_service_->RegisterMetricsProvider(
492 std::unique_ptr<metrics::MetricsProvider>(new PageLoadMetricsProvider())); 494 std::unique_ptr<metrics::MetricsProvider>(new PageLoadMetricsProvider()));
493 #endif // BUILDFLAG(ANDROID_JAVA_UI) 495 #endif // BUILDFLAG(ANDROID_JAVA_UI)
494 496
495 #if defined(OS_WIN) 497 #if defined(OS_WIN)
496 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; 498 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin;
497 metrics_service_->RegisterMetricsProvider( 499 metrics_service_->RegisterMetricsProvider(
498 std::unique_ptr<metrics::MetricsProvider>( 500 std::unique_ptr<metrics::MetricsProvider>(
499 google_update_metrics_provider_)); 501 google_update_metrics_provider_));
500 502
503 base::FilePath user_data_dir;
504 base::FilePath crash_dir;
505 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) ||
506 !base::PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir)) {
507 // If either call fails, then clear both.
508 user_data_dir = base::FilePath();
509 crash_dir = base::FilePath();
510 }
511 watcher_metrics_provider_ = new browser_watcher::WatcherMetricsProviderWin(
512 chrome::GetBrowserExitCodesRegistryPath(), user_data_dir, crash_dir,
513 content::BrowserThread::GetBlockingPool());
501 metrics_service_->RegisterMetricsProvider( 514 metrics_service_->RegisterMetricsProvider(
502 std::unique_ptr<metrics::MetricsProvider>( 515 std::unique_ptr<metrics::MetricsProvider>(watcher_metrics_provider_));
503 new browser_watcher::WatcherMetricsProviderWin(
504 chrome::GetBrowserExitCodesRegistryPath(),
505 content::BrowserThread::GetBlockingPool())));
506 516
507 antivirus_metrics_provider_ = new AntiVirusMetricsProvider( 517 antivirus_metrics_provider_ = new AntiVirusMetricsProvider(
508 content::BrowserThread::GetBlockingPool() 518 content::BrowserThread::GetBlockingPool()
509 ->GetTaskRunnerWithShutdownBehavior( 519 ->GetTaskRunnerWithShutdownBehavior(
510 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)); 520 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN));
511 521
512 metrics_service_->RegisterMetricsProvider( 522 metrics_service_->RegisterMetricsProvider(
513 std::unique_ptr<metrics::MetricsProvider>(antivirus_metrics_provider_)); 523 std::unique_ptr<metrics::MetricsProvider>(antivirus_metrics_provider_));
514 #endif // defined(OS_WIN) 524 #endif // defined(OS_WIN)
515 525
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 #endif // defined(OS_WIN) 623 #endif // defined(OS_WIN)
614 } 624 }
615 625
616 void ChromeMetricsServiceClient::OnInitTaskGotAntiVirusData() { 626 void ChromeMetricsServiceClient::OnInitTaskGotAntiVirusData() {
617 drive_metrics_provider_->GetDriveMetrics( 627 drive_metrics_provider_->GetDriveMetrics(
618 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics, 628 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics,
619 weak_ptr_factory_.GetWeakPtr())); 629 weak_ptr_factory_.GetWeakPtr()));
620 } 630 }
621 631
622 void ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() { 632 void ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() {
633 const base::Closure on_collected_callback = base::Bind(
634 &ChromeMetricsServiceClient::OnInitTaskCollectedPostmortemReports,
Sigurður Ásgeirsson 2016/09/22 13:06:11 ubernit: it's pretty wasteful to create a Closure,
manzagop (departed) 2016/09/22 15:41:57 Done.
635 weak_ptr_factory_.GetWeakPtr());
636
637 #if defined(OS_WIN)
638 watcher_metrics_provider_->CollectPostmortemReports(on_collected_callback);
639 #else
640 on_collected_callback.Run();
641 #endif // defined(OS_WIN)
642 }
643
644 void ChromeMetricsServiceClient::OnInitTaskCollectedPostmortemReports() {
623 finished_init_task_callback_.Run(); 645 finished_init_task_callback_.Run();
624 } 646 }
625 647
626 bool ChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() { 648 bool ChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() {
627 // Upload profiler data at most once per session. 649 // Upload profiler data at most once per session.
628 if (has_uploaded_profiler_data_) 650 if (has_uploaded_profiler_data_)
629 return false; 651 return false;
630 652
631 // For each log, flip a fair coin. Thus, profiler data is sent with the first 653 // For each log, flip a fair coin. Thus, profiler data is sent with the first
632 // log with probability 50%, with the second log with probability 25%, and so 654 // log with probability 50%, with the second log with probability 25%, and so
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } 836 }
815 } 837 }
816 838
817 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { 839 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {
818 metrics_service_->OnApplicationNotIdle(); 840 metrics_service_->OnApplicationNotIdle();
819 } 841 }
820 842
821 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { 843 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() {
822 return metrics::IsCellularLogicEnabled(); 844 return metrics::IsCellularLogicEnabled();
823 } 845 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698