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 #include "chrome/app/chrome_crash_reporter_client.h" | 5 #include "chrome/app/chrome_crash_reporter_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/threading/thread_restrictions.h" | |
14 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/chrome_result_codes.h" | 18 #include "chrome/common/chrome_result_codes.h" |
17 #include "chrome/common/crash_keys.h" | 19 #include "chrome/common/crash_keys.h" |
18 #include "chrome/common/env_vars.h" | 20 #include "chrome/common/env_vars.h" |
21 #include "chrome/installer/util/browser_distribution.h" | |
19 #include "chrome/installer/util/google_update_settings.h" | 22 #include "chrome/installer/util/google_update_settings.h" |
20 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
21 | 24 |
22 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
23 #include <windows.h> | 26 #include <windows.h> |
24 | 27 |
25 #include "base/file_version_info.h" | 28 #include "base/file_version_info.h" |
26 #include "base/win/registry.h" | 29 #include "base/win/registry.h" |
27 #include "chrome/installer/util/google_chrome_sxs_distribution.h" | 30 #include "chrome/installer/util/google_chrome_sxs_distribution.h" |
28 #include "chrome/installer/util/install_util.h" | 31 #include "chrome/installer/util/install_util.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 *version = PRODUCT_VERSION; | 274 *version = PRODUCT_VERSION; |
272 } | 275 } |
273 | 276 |
274 base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() { | 277 base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() { |
275 return base::FilePath(CrashUploadList::kReporterLogFilename); | 278 return base::FilePath(CrashUploadList::kReporterLogFilename); |
276 } | 279 } |
277 #endif | 280 #endif |
278 | 281 |
279 bool ChromeCrashReporterClient::GetCrashDumpLocation( | 282 bool ChromeCrashReporterClient::GetCrashDumpLocation( |
280 base::FilePath* crash_dir) { | 283 base::FilePath* crash_dir) { |
284 #if defined(OS_WIN) | |
285 // In order to be able to start crash handling very early, we do not rely on | |
286 // the PathService being available on Windows. See http://crbug.com/564398. | |
287 if (GetAlternativeCrashDumpLocation(crash_dir)) | |
Mark Mentovai
2015/12/02 22:47:12
This slurps a path out of BREAKPAD_DUMP_LOCATION.
scottmg
2015/12/03 01:40:15
The only place I could find on Windows is https://
| |
288 return true; | |
289 base::FilePath result; | |
290 if (!base::GetLocalAppData(&result)) | |
291 return false; | |
292 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
293 result = result.Append(dist->GetInstallSubDir()); | |
294 result = result.Append(chrome::kUserDataDirname); | |
Mark Mentovai
2015/12/02 22:47:12
Need to manually look for --user-data-dir too?
scottmg
2015/12/03 01:40:15
This is copied from https://code.google.com/p/chro
| |
295 result = result.Append(FILE_PATH_LITERAL("Crashpad")); | |
296 | |
297 // TODO(bauerb): http://crbug.com/259796 | |
298 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
299 if (!base::PathExists(result) && !base::CreateDirectory(result)) | |
Mark Mentovai
2015/12/02 22:47:12
The Crashpad handler doesn’t care if you start it
scottmg
2015/12/03 01:40:15
Done.
| |
300 return false; | |
301 *crash_dir = result; | |
302 return true; | |
303 #else | |
281 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 304 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
282 // location to write breakpad crash dumps can be set. | 305 // location to write breakpad crash dumps can be set. |
283 scoped_ptr<base::Environment> env(base::Environment::Create()); | 306 scoped_ptr<base::Environment> env(base::Environment::Create()); |
284 std::string alternate_crash_dump_location; | 307 std::string alternate_crash_dump_location; |
285 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { | 308 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { |
286 base::FilePath crash_dumps_dir_path = | 309 base::FilePath crash_dumps_dir_path = |
287 base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); | 310 base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); |
288 PathService::Override(chrome::DIR_CRASH_DUMPS, crash_dumps_dir_path); | 311 PathService::Override(chrome::DIR_CRASH_DUMPS, crash_dumps_dir_path); |
289 } | 312 } |
290 | 313 |
291 return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); | 314 return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); |
315 #endif | |
292 } | 316 } |
293 | 317 |
294 size_t ChromeCrashReporterClient::RegisterCrashKeys() { | 318 size_t ChromeCrashReporterClient::RegisterCrashKeys() { |
295 return crash_keys::RegisterChromeCrashKeys(); | 319 return crash_keys::RegisterChromeCrashKeys(); |
296 } | 320 } |
297 | 321 |
298 bool ChromeCrashReporterClient::IsRunningUnattended() { | 322 bool ChromeCrashReporterClient::IsRunningUnattended() { |
299 scoped_ptr<base::Environment> env(base::Environment::Create()); | 323 scoped_ptr<base::Environment> env(base::Environment::Create()); |
300 return env->HasVar(env_vars::kHeadless); | 324 return env->HasVar(env_vars::kHeadless); |
301 } | 325 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 #endif | 359 #endif |
336 | 360 |
337 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 361 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
338 const std::string& process_type) { | 362 const std::string& process_type) { |
339 return process_type == switches::kRendererProcess || | 363 return process_type == switches::kRendererProcess || |
340 process_type == switches::kPluginProcess || | 364 process_type == switches::kPluginProcess || |
341 process_type == switches::kPpapiPluginProcess || | 365 process_type == switches::kPpapiPluginProcess || |
342 process_type == switches::kZygoteProcess || | 366 process_type == switches::kZygoteProcess || |
343 process_type == switches::kGpuProcess; | 367 process_type == switches::kGpuProcess; |
344 } | 368 } |
OLD | NEW |