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

Side by Side Diff: chrome/app/chrome_crash_reporter_client_win.cc

Issue 2549593002: Revert of Make Crashpad use the user data dir, rather than always default location (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « chrome/app/BUILD.gn ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <assert.h> 9 #include <assert.h>
10 #include <windows.h> 10 #include <windows.h>
11 #include <shellapi.h> 11 #include <shellapi.h>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/debug/crash_logging.h" 16 #include "base/debug/crash_logging.h"
17 #include "base/debug/leak_annotations.h" 17 #include "base/debug/leak_annotations.h"
18 #include "base/format_macros.h" 18 #include "base/format_macros.h"
19 #include "chrome/common/chrome_result_codes.h" 19 #include "chrome/common/chrome_result_codes.h"
20 #include "chrome/install_static/install_details.h" 20 #include "chrome/install_static/install_details.h"
21 #include "chrome/install_static/install_util.h" 21 #include "chrome/install_static/install_util.h"
22 #include "chrome/install_static/user_data_dir.h"
23 #include "components/crash/content/app/crashpad.h" 22 #include "components/crash/content/app/crashpad.h"
24 #include "components/crash/core/common/crash_keys.h" 23 #include "components/crash/core/common/crash_keys.h"
25 24
26 namespace { 25 namespace {
27 26
28 // TODO(ananta) 27 // TODO(ananta)
29 // When the new crash key map implementation lands, we should remove the 28 // When the new crash key map implementation lands, we should remove the
30 // constants defined below, the RegisterCrashKeysHelper function, the 29 // constants defined below, the RegisterCrashKeysHelper function, the
31 // RegisterCrashKeys function in the crash_keys::CrashReporterClient interface 30 // RegisterCrashKeys function in the crash_keys::CrashReporterClient interface
32 // and the snprintf function defined here. 31 // and the snprintf function defined here.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 #if !defined(NACL_WIN64) 245 #if !defined(NACL_WIN64)
247 // static 246 // static
248 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { 247 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() {
249 static ChromeCrashReporterClient* instance = nullptr; 248 static ChromeCrashReporterClient* instance = nullptr;
250 if (instance) 249 if (instance)
251 return; 250 return;
252 251
253 instance = new ChromeCrashReporterClient(); 252 instance = new ChromeCrashReporterClient();
254 ANNOTATE_LEAKING_OBJECT_PTR(instance); 253 ANNOTATE_LEAKING_OBJECT_PTR(instance);
255 254
256 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( 255 std::string process_type = install_static::GetSwitchValueFromCommandLine(
257 ::GetCommandLine(), install_static::kProcessType); 256 ::GetCommandLineA(), install_static::kProcessType);
258 if (process_type != install_static::kCrashpadHandler) { 257 if (process_type != install_static::kCrashpadHandler) {
259 crash_reporter::SetCrashReporterClient(instance); 258 crash_reporter::SetCrashReporterClient(instance);
260 crash_reporter::InitializeCrashpadWithEmbeddedHandler( 259 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(),
261 process_type.empty(), install_static::UTF16ToUTF8(process_type)); 260 process_type);
262 } 261 }
263 } 262 }
264 #endif // NACL_WIN64 263 #endif // NACL_WIN64
265 264
266 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( 265 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation(
267 base::string16* crash_dir) { 266 base::string16* crash_dir) {
268 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 267 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
269 // location to write breakpad crash dumps can be set. 268 // location to write breakpad crash dumps can be set.
270 *crash_dir = 269 *crash_dir =
271 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); 270 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION");
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 base::string16* crash_dir) { 363 base::string16* crash_dir) {
365 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 364 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
366 // location to write breakpad crash dumps can be set. 365 // location to write breakpad crash dumps can be set.
367 // If this environment variable exists, then for the time being, 366 // If this environment variable exists, then for the time being,
368 // short-circuit how it's handled on Windows. Honoring this 367 // short-circuit how it's handled on Windows. Honoring this
369 // variable is required in order to symbolize stack traces in 368 // variable is required in order to symbolize stack traces in
370 // Telemetry based tests: http://crbug.com/561763. 369 // Telemetry based tests: http://crbug.com/561763.
371 if (GetAlternativeCrashDumpLocation(crash_dir)) 370 if (GetAlternativeCrashDumpLocation(crash_dir))
372 return true; 371 return true;
373 372
374 *crash_dir = install_static::GetCrashDumpLocation(); 373 // TODO(scottmg): Consider supporting --user-data-dir. See
375 return true; 374 // https://crbug.com/565446.
375 return install_static::GetDefaultCrashDumpLocation(crash_dir);
376 } 376 }
377 377
378 bool ChromeCrashReporterClient::GetCrashMetricsLocation( 378 bool ChromeCrashReporterClient::GetCrashMetricsLocation(
379 base::string16* metrics_dir) { 379 base::string16* metrics_dir) {
380 return install_static::GetUserDataDirectory(metrics_dir, nullptr); 380 return install_static::GetDefaultUserDataDirectory(metrics_dir);
381 } 381 }
382 382
383 // TODO(ananta) 383 // TODO(ananta)
384 // This function should be removed when the new crash key map implementation 384 // This function should be removed when the new crash key map implementation
385 // lands. 385 // lands.
386 size_t ChromeCrashReporterClient::RegisterCrashKeys() { 386 size_t ChromeCrashReporterClient::RegisterCrashKeys() {
387 return RegisterCrashKeysHelper(); 387 return RegisterCrashKeysHelper();
388 } 388 }
389 389
390 bool ChromeCrashReporterClient::IsRunningUnattended() { 390 bool ChromeCrashReporterClient::IsRunningUnattended() {
391 return install_static::HasEnvironmentVariable16(install_static::kHeadless); 391 return install_static::HasEnvironmentVariable16(install_static::kHeadless);
392 } 392 }
393 393
394 bool ChromeCrashReporterClient::GetCollectStatsConsent() { 394 bool ChromeCrashReporterClient::GetCollectStatsConsent() {
395 return install_static::GetCollectStatsConsent(); 395 return install_static::GetCollectStatsConsent();
396 } 396 }
397 397
398 bool ChromeCrashReporterClient::GetCollectStatsInSample() { 398 bool ChromeCrashReporterClient::GetCollectStatsInSample() {
399 return install_static::GetCollectStatsInSample(); 399 return install_static::GetCollectStatsInSample();
400 } 400 }
401 401
402 bool ChromeCrashReporterClient::EnableBreakpadForProcess( 402 bool ChromeCrashReporterClient::EnableBreakpadForProcess(
403 const std::string& process_type) { 403 const std::string& process_type) {
404 // This is not used by Crashpad (at least on Windows). 404 return process_type == install_static::kRendererProcess ||
405 NOTREACHED(); 405 process_type == install_static::kPpapiPluginProcess ||
406 return true; 406 process_type == install_static::kGpuProcess;
407 } 407 }
OLDNEW
« no previous file with comments | « chrome/app/BUILD.gn ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698