| OLD | NEW |
| 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> |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const GetExecutableDetailsCallback& exe_details_cb, |
| 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 exe_details_cb_(exe_details_cb), |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // Create a database. Note: Chrome already has a g_database in crashpad.cc but | 304 // Create a database. Note: Chrome already has a g_database in crashpad.cc but |
| 303 // it has internal linkage. Create a new one. | 305 // it has internal linkage. Create a new one. |
| 304 std::unique_ptr<crashpad::CrashReportDatabase> crashpad_database = | 306 std::unique_ptr<crashpad::CrashReportDatabase> crashpad_database = |
| 305 crashpad::CrashReportDatabase::InitializeWithoutCreating(crash_dir_); | 307 crashpad::CrashReportDatabase::InitializeWithoutCreating(crash_dir_); |
| 306 if (!crashpad_database) { | 308 if (!crashpad_database) { |
| 307 LOG(ERROR) << "Failed to initialize a CrashPad database."; | 309 LOG(ERROR) << "Failed to initialize a CrashPad database."; |
| 308 LogCollectionInitStatus(CRASHPAD_DATABASE_INIT_FAILED); | 310 LogCollectionInitStatus(CRASHPAD_DATABASE_INIT_FAILED); |
| 309 return; | 311 return; |
| 310 } | 312 } |
| 311 | 313 |
| 312 // Note: not caching the histogram pointer as this function isn't expected to | |
| 313 // be called multiple times. | |
| 314 LogCollectionInitStatus(INIT_SUCCESS); | 314 LogCollectionInitStatus(INIT_SUCCESS); |
| 315 | 315 |
| 316 // TODO(manzagop): fix incorrect version attribution on update. | 316 // TODO(manzagop): fix incorrect version attribution on update. |
| 317 PostmortemReportCollector collector; | 317 base::string16 product_name, version_number, channel_name; |
| 318 exe_details_cb_.Run(&product_name, &version_number, &channel_name); |
| 319 PostmortemReportCollector collector(base::UTF16ToUTF8(product_name), |
| 320 base::UTF16ToUTF8(version_number), |
| 321 base::UTF16ToUTF8(channel_name)); |
| 318 collector.CollectAndSubmitForUpload(stability_dir, GetStabilityFilePattern(), | 322 collector.CollectAndSubmitForUpload(stability_dir, GetStabilityFilePattern(), |
| 319 excluded_debug_files, | 323 excluded_debug_files, |
| 320 crashpad_database.get()); | 324 crashpad_database.get()); |
| 321 } | 325 } |
| 322 | 326 |
| 323 } // namespace browser_watcher | 327 } // namespace browser_watcher |
| OLD | NEW |