OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
scottmg
2017/05/19 17:46:52
In the CL description "On successful collection th
manzagop (departed)
2017/05/19 22:02:06
Thanks! ("is deleted.") Done.
| |
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 // TODO(ananta/scottmg) | 5 // TODO(ananta/scottmg) |
6 // Add test coverage for Crashpad. | 6 // Add test coverage for Crashpad. |
7 #include "chrome/app/chrome_crash_reporter_client_win.h" | 7 #include "chrome/app/chrome_crash_reporter_client_win.h" |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
11 #include <assert.h> | 11 #include <assert.h> |
12 #include <shellapi.h> | 12 #include <shellapi.h> |
13 | 13 |
14 #include <iterator> | 14 #include <iterator> |
15 #include <memory> | 15 #include <memory> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | |
17 | 18 |
18 #include "base/command_line.h" | 19 #include "base/command_line.h" |
19 #include "base/debug/crash_logging.h" | 20 #include "base/debug/crash_logging.h" |
20 #include "base/debug/leak_annotations.h" | 21 #include "base/debug/leak_annotations.h" |
21 #include "base/format_macros.h" | 22 #include "base/format_macros.h" |
22 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
23 #include "chrome/common/chrome_result_codes.h" | 24 #include "chrome/common/chrome_result_codes.h" |
25 #include "chrome/install_static/install_details.h" | |
24 #include "chrome/install_static/install_util.h" | 26 #include "chrome/install_static/install_util.h" |
25 #include "chrome/install_static/user_data_dir.h" | 27 #include "chrome/install_static/user_data_dir.h" |
26 #include "components/crash/content/app/crashpad.h" | 28 #include "components/crash/content/app/crashpad.h" |
27 #include "components/crash/core/common/crash_keys.h" | 29 #include "components/crash/core/common/crash_keys.h" |
28 #include "components/version_info/channel.h" | 30 #include "components/version_info/channel.h" |
29 | 31 |
30 namespace { | 32 namespace { |
31 | 33 |
32 // TODO(ananta) | 34 // TODO(ananta) |
33 // When the new crash key map implementation lands, we should remove the | 35 // When the new crash key map implementation lands, we should remove the |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { | 235 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { |
234 static ChromeCrashReporterClient* instance = nullptr; | 236 static ChromeCrashReporterClient* instance = nullptr; |
235 if (instance) | 237 if (instance) |
236 return; | 238 return; |
237 | 239 |
238 instance = new ChromeCrashReporterClient(); | 240 instance = new ChromeCrashReporterClient(); |
239 ANNOTATE_LEAKING_OBJECT_PTR(instance); | 241 ANNOTATE_LEAKING_OBJECT_PTR(instance); |
240 | 242 |
241 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( | 243 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( |
242 ::GetCommandLine(), install_static::kProcessType); | 244 ::GetCommandLine(), install_static::kProcessType); |
245 std::wstring user_data_dir = | |
246 install_static::InstallDetails::Get().user_data_dir(); | |
grt (UTC plus 2)
2017/05/19 08:15:50
since this is such a mouthful, i've been putting h
manzagop (departed)
2017/05/19 22:02:06
Done.
| |
243 // Don't set up Crashpad crash reporting in the Crashpad handler itself, nor | 247 // Don't set up Crashpad crash reporting in the Crashpad handler itself, nor |
244 // in the fallback crash handler for the Crashpad handler process. | 248 // in the fallback crash handler for the Crashpad handler process. |
245 if (process_type != install_static::kCrashpadHandler && | 249 if (process_type != install_static::kCrashpadHandler && |
246 process_type != install_static::kFallbackHandler) { | 250 process_type != install_static::kFallbackHandler) { |
247 crash_reporter::SetCrashReporterClient(instance); | 251 crash_reporter::SetCrashReporterClient(instance); |
248 crash_reporter::InitializeCrashpadWithEmbeddedHandler( | 252 crash_reporter::InitializeCrashpadWithEmbeddedHandler( |
249 process_type.empty(), install_static::UTF16ToUTF8(process_type)); | 253 process_type.empty(), install_static::UTF16ToUTF8(process_type), |
254 install_static::UTF16ToUTF8(user_data_dir)); | |
250 } | 255 } |
251 } | 256 } |
252 #endif // NACL_WIN64 | 257 #endif // NACL_WIN64 |
253 | 258 |
254 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( | 259 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( |
255 base::string16* crash_dir) { | 260 base::string16* crash_dir) { |
256 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 261 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
257 // location to write breakpad crash dumps can be set. | 262 // location to write breakpad crash dumps can be set. |
258 *crash_dir = | 263 *crash_dir = |
259 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); | 264 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 // Telemetry based tests: http://crbug.com/561763. | 357 // Telemetry based tests: http://crbug.com/561763. |
353 if (GetAlternativeCrashDumpLocation(crash_dir)) | 358 if (GetAlternativeCrashDumpLocation(crash_dir)) |
354 return true; | 359 return true; |
355 | 360 |
356 *crash_dir = install_static::GetCrashDumpLocation(); | 361 *crash_dir = install_static::GetCrashDumpLocation(); |
357 return true; | 362 return true; |
358 } | 363 } |
359 | 364 |
360 bool ChromeCrashReporterClient::GetCrashMetricsLocation( | 365 bool ChromeCrashReporterClient::GetCrashMetricsLocation( |
361 base::string16* metrics_dir) { | 366 base::string16* metrics_dir) { |
362 return install_static::GetUserDataDirectory(metrics_dir, nullptr); | 367 *metrics_dir = install_static::InstallDetails::Get().user_data_dir(); |
368 return true; | |
363 } | 369 } |
364 | 370 |
365 // TODO(ananta) | 371 // TODO(ananta) |
366 // This function should be removed when the new crash key map implementation | 372 // This function should be removed when the new crash key map implementation |
367 // lands. | 373 // lands. |
368 size_t ChromeCrashReporterClient::RegisterCrashKeys() { | 374 size_t ChromeCrashReporterClient::RegisterCrashKeys() { |
369 return RegisterCrashKeysHelper(); | 375 return RegisterCrashKeysHelper(); |
370 } | 376 } |
371 | 377 |
372 bool ChromeCrashReporterClient::IsRunningUnattended() { | 378 bool ChromeCrashReporterClient::IsRunningUnattended() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 | 414 |
409 return base::RandDouble() < probability; | 415 return base::RandDouble() < probability; |
410 } | 416 } |
411 | 417 |
412 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 418 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
413 const std::string& process_type) { | 419 const std::string& process_type) { |
414 // This is not used by Crashpad (at least on Windows). | 420 // This is not used by Crashpad (at least on Windows). |
415 NOTREACHED(); | 421 NOTREACHED(); |
416 return true; | 422 return true; |
417 } | 423 } |
OLD | NEW |