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

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

Issue 2128683002: Collect unclean shutdown debug information (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracker
Patch Set: Merge Created 4 years, 3 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 chromeos_metrics_provider_(nullptr), 222 chromeos_metrics_provider_(nullptr),
223 #endif 223 #endif
224 waiting_for_collect_final_metrics_step_(false), 224 waiting_for_collect_final_metrics_step_(false),
225 num_async_histogram_fetches_in_progress_(0), 225 num_async_histogram_fetches_in_progress_(0),
226 profiler_metrics_provider_(nullptr), 226 profiler_metrics_provider_(nullptr),
227 #if defined(ENABLE_PLUGINS) 227 #if defined(ENABLE_PLUGINS)
228 plugin_metrics_provider_(nullptr), 228 plugin_metrics_provider_(nullptr),
229 #endif 229 #endif
230 #if defined(OS_WIN) 230 #if defined(OS_WIN)
231 google_update_metrics_provider_(nullptr), 231 google_update_metrics_provider_(nullptr),
232 watcher_metrics_provider_(nullptr),
233 antivirus_metrics_provider_(nullptr),
232 #endif 234 #endif
233 drive_metrics_provider_(nullptr), 235 drive_metrics_provider_(nullptr),
234 start_time_(base::TimeTicks::Now()), 236 start_time_(base::TimeTicks::Now()),
235 has_uploaded_profiler_data_(false), 237 has_uploaded_profiler_data_(false),
236 weak_ptr_factory_(this) { 238 weak_ptr_factory_(this) {
237 DCHECK(thread_checker_.CalledOnValidThread()); 239 DCHECK(thread_checker_.CalledOnValidThread());
238 RecordCommandLineMetrics(); 240 RecordCommandLineMetrics();
239 RegisterForNotifications(); 241 RegisterForNotifications();
240 } 242 }
241 243
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 metrics_service_->RegisterMetricsProvider( 464 metrics_service_->RegisterMetricsProvider(
463 std::unique_ptr<metrics::MetricsProvider>(new PageLoadMetricsProvider())); 465 std::unique_ptr<metrics::MetricsProvider>(new PageLoadMetricsProvider()));
464 #endif // BUILDFLAG(ANDROID_JAVA_UI) 466 #endif // BUILDFLAG(ANDROID_JAVA_UI)
465 467
466 #if defined(OS_WIN) 468 #if defined(OS_WIN)
467 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; 469 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin;
468 metrics_service_->RegisterMetricsProvider( 470 metrics_service_->RegisterMetricsProvider(
469 std::unique_ptr<metrics::MetricsProvider>( 471 std::unique_ptr<metrics::MetricsProvider>(
470 google_update_metrics_provider_)); 472 google_update_metrics_provider_));
471 473
474 base::FilePath user_data_dir;
475 base::FilePath crash_dir;
476 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) ||
477 !base::PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir)) {
478 // If either call fails, then clear both.
479 user_data_dir = base::FilePath();
480 crash_dir = base::FilePath();
481 }
482 watcher_metrics_provider_ = new browser_watcher::WatcherMetricsProviderWin(
483 chrome::GetBrowserExitCodesRegistryPath(), user_data_dir, crash_dir,
484 content::BrowserThread::GetBlockingPool());
472 metrics_service_->RegisterMetricsProvider( 485 metrics_service_->RegisterMetricsProvider(
473 std::unique_ptr<metrics::MetricsProvider>( 486 std::unique_ptr<metrics::MetricsProvider>(watcher_metrics_provider_));
474 new browser_watcher::WatcherMetricsProviderWin(
475 chrome::GetBrowserExitCodesRegistryPath(),
476 content::BrowserThread::GetBlockingPool())));
477 487
478 antivirus_metrics_provider_ = new AntiVirusMetricsProvider( 488 antivirus_metrics_provider_ = new AntiVirusMetricsProvider(
479 content::BrowserThread::GetBlockingPool() 489 content::BrowserThread::GetBlockingPool()
480 ->GetTaskRunnerWithShutdownBehavior( 490 ->GetTaskRunnerWithShutdownBehavior(
481 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)); 491 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN));
482 492
483 metrics_service_->RegisterMetricsProvider( 493 metrics_service_->RegisterMetricsProvider(
484 std::unique_ptr<metrics::MetricsProvider>(antivirus_metrics_provider_)); 494 std::unique_ptr<metrics::MetricsProvider>(antivirus_metrics_provider_));
485 #endif // defined(OS_WIN) 495 #endif // defined(OS_WIN)
486 496
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 #endif // defined(OS_WIN) 594 #endif // defined(OS_WIN)
585 } 595 }
586 596
587 void ChromeMetricsServiceClient::OnInitTaskGotAntiVirusData() { 597 void ChromeMetricsServiceClient::OnInitTaskGotAntiVirusData() {
588 drive_metrics_provider_->GetDriveMetrics( 598 drive_metrics_provider_->GetDriveMetrics(
589 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics, 599 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics,
590 weak_ptr_factory_.GetWeakPtr())); 600 weak_ptr_factory_.GetWeakPtr()));
591 } 601 }
592 602
593 void ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() { 603 void ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() {
604 const base::Closure on_collected_callback = base::Bind(
605 &ChromeMetricsServiceClient::OnInitTaskCollectedPostmortemReports,
606 weak_ptr_factory_.GetWeakPtr());
607
608 #if defined(OS_WIN)
609 watcher_metrics_provider_->CollectPostmortemReports(on_collected_callback);
610 #else
611 on_collected_callback.Run();
612 #endif // defined(OS_WIN)
613 }
614
615 void ChromeMetricsServiceClient::OnInitTaskCollectedPostmortemReports() {
594 finished_init_task_callback_.Run(); 616 finished_init_task_callback_.Run();
595 } 617 }
596 618
597 bool ChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() { 619 bool ChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() {
598 // Upload profiler data at most once per session. 620 // Upload profiler data at most once per session.
599 if (has_uploaded_profiler_data_) 621 if (has_uploaded_profiler_data_)
600 return false; 622 return false;
601 623
602 // For each log, flip a fair coin. Thus, profiler data is sent with the first 624 // For each log, flip a fair coin. Thus, profiler data is sent with the first
603 // log with probability 50%, with the second log with probability 25%, and so 625 // 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
785 } 807 }
786 } 808 }
787 809
788 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { 810 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {
789 metrics_service_->OnApplicationNotIdle(); 811 metrics_service_->OnApplicationNotIdle();
790 } 812 }
791 813
792 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { 814 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() {
793 return metrics::IsCellularLogicEnabled(); 815 return metrics::IsCellularLogicEnabled();
794 } 816 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.h ('k') | components/browser_watcher/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698