OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // 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" |
24 #include "chrome/install_static/install_util.h" | 25 #include "chrome/install_static/install_util.h" |
25 #include "chrome/install_static/user_data_dir.h" | 26 #include "chrome/install_static/user_data_dir.h" |
26 #include "components/crash/content/app/crashpad.h" | 27 #include "components/crash/content/app/crashpad.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { | 251 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { |
251 static ChromeCrashReporterClient* instance = nullptr; | 252 static ChromeCrashReporterClient* instance = nullptr; |
252 if (instance) | 253 if (instance) |
253 return; | 254 return; |
254 | 255 |
255 instance = new ChromeCrashReporterClient(); | 256 instance = new ChromeCrashReporterClient(); |
256 ANNOTATE_LEAKING_OBJECT_PTR(instance); | 257 ANNOTATE_LEAKING_OBJECT_PTR(instance); |
257 | 258 |
258 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( | 259 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( |
259 ::GetCommandLine(), install_static::kProcessType); | 260 ::GetCommandLine(), install_static::kProcessType); |
| 261 std::wstring user_data_dir; |
| 262 // DO NOT SUBMIT: validate use of CHECK. |
| 263 CHECK(install_static::GetUserDataDirectory(&user_data_dir, nullptr)); |
260 // Don't set up Crashpad crash reporting in the Crashpad handler itself, nor | 264 // Don't set up Crashpad crash reporting in the Crashpad handler itself, nor |
261 // in the fallback crash handler for the Crashpad handler process. | 265 // in the fallback crash handler for the Crashpad handler process. |
262 if (process_type != install_static::kCrashpadHandler && | 266 if (process_type != install_static::kCrashpadHandler && |
263 process_type != install_static::kFallbackHandler) { | 267 process_type != install_static::kFallbackHandler) { |
264 crash_reporter::SetCrashReporterClient(instance); | 268 crash_reporter::SetCrashReporterClient(instance); |
265 crash_reporter::InitializeCrashpadWithEmbeddedHandler( | 269 crash_reporter::InitializeCrashpadWithEmbeddedHandler( |
266 process_type.empty(), install_static::UTF16ToUTF8(process_type)); | 270 process_type.empty(), install_static::UTF16ToUTF8(process_type), |
| 271 install_static::UTF16ToUTF8(user_data_dir)); |
267 } | 272 } |
268 } | 273 } |
269 #endif // NACL_WIN64 | 274 #endif // NACL_WIN64 |
270 | 275 |
271 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( | 276 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( |
272 base::string16* crash_dir) { | 277 base::string16* crash_dir) { |
273 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 278 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
274 // location to write breakpad crash dumps can be set. | 279 // location to write breakpad crash dumps can be set. |
275 *crash_dir = | 280 *crash_dir = |
276 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); | 281 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 430 |
426 return base::RandDouble() < probability; | 431 return base::RandDouble() < probability; |
427 } | 432 } |
428 | 433 |
429 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 434 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
430 const std::string& process_type) { | 435 const std::string& process_type) { |
431 // This is not used by Crashpad (at least on Windows). | 436 // This is not used by Crashpad (at least on Windows). |
432 NOTREACHED(); | 437 NOTREACHED(); |
433 return true; | 438 return true; |
434 } | 439 } |
OLD | NEW |