| Index: components/browser_watcher/watcher_metrics_provider_win.cc
|
| diff --git a/components/browser_watcher/watcher_metrics_provider_win.cc b/components/browser_watcher/watcher_metrics_provider_win.cc
|
| index 6376079ba2335101e2e487c5f877982272c6ee57..dcd7881010eb22f203e4b27eaa5dc58d597c206d 100644
|
| --- a/components/browser_watcher/watcher_metrics_provider_win.cc
|
| +++ b/components/browser_watcher/watcher_metrics_provider_win.cc
|
| @@ -14,6 +14,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/feature_list.h"
|
| +#include "base/metrics/field_trial_params.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/metrics/histogram_base.h"
|
| #include "base/metrics/histogram_macros.h"
|
| @@ -223,36 +224,49 @@ void WatcherMetricsProviderWin::CollectPostmortemReports(
|
| done_callback);
|
| }
|
|
|
| +// TODO(manzagop): consider mechanisms for partial collection if this is to be
|
| +// used on a critical path.
|
| void WatcherMetricsProviderWin::CollectPostmortemReportsOnBlockingPool() {
|
| - // Note: the feature controls both instrumentation and collection.
|
| + SCOPED_UMA_HISTOGRAM_TIMER("ActivityTracker.Collect.TotalTime");
|
| +
|
| bool is_stability_debugging_on =
|
| base::FeatureList::IsEnabled(browser_watcher::kStabilityDebuggingFeature);
|
| if (!is_stability_debugging_on) {
|
| - // TODO(manzagop): delete possible leftover data.
|
| - return;
|
| + return; // TODO(manzagop): scan for possible data to delete?
|
| }
|
|
|
| - SCOPED_UMA_HISTOGRAM_TIMER("ActivityTracker.Collect.TotalTime");
|
| -
|
| if (user_data_dir_.empty() || crash_dir_.empty()) {
|
| - LOG(ERROR) << "User data directory or crash directory is unknown.";
|
| LogCollectionInitStatus(UNKNOWN_DIR);
|
| return;
|
| }
|
|
|
| - // Determine the stability directory and the stability file for the current
|
| - // process.
|
| + // Determine which files to harvest.
|
| base::FilePath stability_dir = GetStabilityDir(user_data_dir_);
|
| +
|
| base::FilePath current_stability_file;
|
| if (!GetStabilityFileForProcess(base::Process::Current(), user_data_dir_,
|
| ¤t_stability_file)) {
|
| - LOG(ERROR) << "Failed to get the current stability file.";
|
| LogCollectionInitStatus(GET_STABILITY_FILE_PATH_FAILED);
|
| return;
|
| }
|
| - const std::set<base::FilePath>& excluded_debug_files = {
|
| + const std::set<base::FilePath>& excluded_stability_files = {
|
| current_stability_file};
|
|
|
| + std::vector<base::FilePath> stability_files = GetStabilityFiles(
|
| + stability_dir, GetStabilityFilePattern(), excluded_stability_files);
|
| + UMA_HISTOGRAM_COUNTS_100("ActivityTracker.Collect.StabilityFileCount",
|
| + stability_files.size());
|
| +
|
| + // If postmortem collection is disabled, delete the files.
|
| + const bool should_collect = base::GetFieldTrialParamByFeatureAsBool(
|
| + browser_watcher::kStabilityDebuggingFeature,
|
| + browser_watcher::kCollectPostmortemParam, false);
|
| + if (!should_collect) {
|
| + PostmortemDeleter deleter;
|
| + deleter.Process(stability_files);
|
| + return;
|
| + }
|
| +
|
| // Create a database. Note: Chrome already has a g_database in crashpad.cc but
|
| // it has internal linkage. Create a new one.
|
| std::unique_ptr<crashpad::CrashReportDatabase> crashpad_database =
|
| @@ -273,10 +287,8 @@ void WatcherMetricsProviderWin::CollectPostmortemReportsOnBlockingPool() {
|
| SystemSessionAnalyzer analyzer(kSystemSessionsToInspect);
|
| PostmortemReportCollector collector(
|
| base::UTF16ToUTF8(product_name), base::UTF16ToUTF8(version_number),
|
| - base::UTF16ToUTF8(channel_name), &analyzer);
|
| - collector.CollectAndSubmitAllPendingReports(
|
| - stability_dir, GetStabilityFilePattern(), excluded_debug_files,
|
| - crashpad_database.get());
|
| + base::UTF16ToUTF8(channel_name), crashpad_database.get(), &analyzer);
|
| + collector.Process(stability_files);
|
| }
|
|
|
| } // namespace browser_watcher
|
|
|