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

Side by Side Diff: components/browser_watcher/watcher_metrics_provider_win.cc

Issue 2372633002: Use the correct product/version for postmortem reports (Closed)
Patch Set: Direct access to GetExecutableVersionDetails via ChromePostmortemReportCollector 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/browser_watcher/watcher_metrics_provider_win.h" 5 #include "components/browser_watcher/watcher_metrics_provider_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <utility>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/bind.h" 15 #include "base/bind.h"
15 #include "base/feature_list.h" 16 #include "base/feature_list.h"
16 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
17 #include "base/metrics/histogram_base.h" 18 #include "base/metrics/histogram_base.h"
18 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
19 #include "base/metrics/sparse_histogram.h" 20 #include "base/metrics/sparse_histogram.h"
20 #include "base/process/process.h" 21 #include "base/process/process.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_piece.h" 23 #include "base/strings/string_piece.h"
23 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
24 #include "base/win/registry.h" 25 #include "base/win/registry.h"
25 #include "components/browser_watcher/features.h" 26 #include "components/browser_watcher/features.h"
26 #include "components/browser_watcher/postmortem_report_collector.h"
27 #include "components/browser_watcher/stability_debugging_win.h" 27 #include "components/browser_watcher/stability_debugging_win.h"
28 #include "third_party/crashpad/crashpad/client/crash_report_database.h" 28 #include "third_party/crashpad/crashpad/client/crash_report_database.h"
29 29
30 namespace browser_watcher { 30 namespace browser_watcher {
31 31
32 namespace { 32 namespace {
33 33
34 // Process ID APIs on Windows talk in DWORDs, whereas for string formatting 34 // Process ID APIs on Windows talk in DWORDs, whereas for string formatting
35 // and parsing, this code uses int. In practice there are no process IDs with 35 // and parsing, this code uses int. In practice there are no process IDs with
36 // the high bit set on Windows, so there's no danger of overflow if this is 36 // the high bit set on Windows, so there's no danger of overflow if this is
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 } // namespace 211 } // namespace
212 212
213 const char WatcherMetricsProviderWin::kBrowserExitCodeHistogramName[] = 213 const char WatcherMetricsProviderWin::kBrowserExitCodeHistogramName[] =
214 "Stability.BrowserExitCodes"; 214 "Stability.BrowserExitCodes";
215 215
216 WatcherMetricsProviderWin::WatcherMetricsProviderWin( 216 WatcherMetricsProviderWin::WatcherMetricsProviderWin(
217 const base::string16& registry_path, 217 const base::string16& registry_path,
218 const base::FilePath& user_data_dir, 218 const base::FilePath& user_data_dir,
219 const base::FilePath& crash_dir, 219 const base::FilePath& crash_dir,
220 std::unique_ptr<PostmortemReportCollector> collector,
220 base::TaskRunner* io_task_runner) 221 base::TaskRunner* io_task_runner)
221 : recording_enabled_(false), 222 : recording_enabled_(false),
222 cleanup_scheduled_(false), 223 cleanup_scheduled_(false),
223 registry_path_(registry_path), 224 registry_path_(registry_path),
224 user_data_dir_(user_data_dir), 225 user_data_dir_(user_data_dir),
225 crash_dir_(crash_dir), 226 crash_dir_(crash_dir),
227 collector_(std::move(collector)),
226 io_task_runner_(io_task_runner), 228 io_task_runner_(io_task_runner),
227 weak_ptr_factory_(this) { 229 weak_ptr_factory_(this) {
228 DCHECK(io_task_runner_); 230 DCHECK(io_task_runner_);
229 } 231 }
230 232
231 WatcherMetricsProviderWin::~WatcherMetricsProviderWin() { 233 WatcherMetricsProviderWin::~WatcherMetricsProviderWin() {
232 } 234 }
233 235
234 void WatcherMetricsProviderWin::OnRecordingEnabled() { 236 void WatcherMetricsProviderWin::OnRecordingEnabled() {
235 recording_enabled_ = true; 237 recording_enabled_ = true;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 272 }
271 273
272 void WatcherMetricsProviderWin::CollectPostmortemReportsOnBlockingPool() { 274 void WatcherMetricsProviderWin::CollectPostmortemReportsOnBlockingPool() {
273 // Note: the feature controls both instrumentation and collection. 275 // Note: the feature controls both instrumentation and collection.
274 bool is_stability_debugging_on = 276 bool is_stability_debugging_on =
275 base::FeatureList::IsEnabled(browser_watcher::kStabilityDebuggingFeature); 277 base::FeatureList::IsEnabled(browser_watcher::kStabilityDebuggingFeature);
276 if (!is_stability_debugging_on) { 278 if (!is_stability_debugging_on) {
277 // TODO(manzagop): delete possible leftover data. 279 // TODO(manzagop): delete possible leftover data.
278 return; 280 return;
279 } 281 }
282 DCHECK_NE(nullptr, collector_.get());
280 283
281 SCOPED_UMA_HISTOGRAM_TIMER("ActivityTracker.Collect.TotalTime"); 284 SCOPED_UMA_HISTOGRAM_TIMER("ActivityTracker.Collect.TotalTime");
282 285
283 if (user_data_dir_.empty() || crash_dir_.empty()) { 286 if (user_data_dir_.empty() || crash_dir_.empty()) {
284 LOG(ERROR) << "User data directory or crash directory is unknown."; 287 LOG(ERROR) << "User data directory or crash directory is unknown.";
285 LogCollectionInitStatus(UNKNOWN_DIR); 288 LogCollectionInitStatus(UNKNOWN_DIR);
286 return; 289 return;
287 } 290 }
288 291
289 // Determine the stability directory and the stability file for the current 292 // Determine the stability directory and the stability file for the current
(...skipping 17 matching lines...) Expand all
307 LOG(ERROR) << "Failed to initialize a CrashPad database."; 310 LOG(ERROR) << "Failed to initialize a CrashPad database.";
308 LogCollectionInitStatus(CRASHPAD_DATABASE_INIT_FAILED); 311 LogCollectionInitStatus(CRASHPAD_DATABASE_INIT_FAILED);
309 return; 312 return;
310 } 313 }
311 314
312 // Note: not caching the histogram pointer as this function isn't expected to 315 // Note: not caching the histogram pointer as this function isn't expected to
313 // be called multiple times. 316 // be called multiple times.
314 LogCollectionInitStatus(INIT_SUCCESS); 317 LogCollectionInitStatus(INIT_SUCCESS);
315 318
316 // TODO(manzagop): fix incorrect version attribution on update. 319 // TODO(manzagop): fix incorrect version attribution on update.
317 PostmortemReportCollector collector; 320 collector_->CollectAndSubmitForUpload(
318 collector.CollectAndSubmitForUpload(stability_dir, GetStabilityFilePattern(), 321 stability_dir, GetStabilityFilePattern(), excluded_debug_files,
319 excluded_debug_files, 322 crashpad_database.get());
320 crashpad_database.get());
321 } 323 }
322 324
323 } // namespace browser_watcher 325 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698