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/logging.h" | 10 #include "base/logging.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/chrome_result_codes.h" | 16 #include "chrome/common/chrome_result_codes.h" |
17 #include "chrome/common/crash_keys.h" | 17 #include "chrome/common/crash_keys.h" |
18 #include "chrome/common/env_vars.h" | 18 #include "chrome/common/env_vars.h" |
| 19 #include "chrome/installer/util/browser_distribution.h" |
19 #include "chrome/installer/util/google_update_settings.h" | 20 #include "chrome/installer/util/google_update_settings.h" |
20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
21 | 22 |
22 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
23 #include <windows.h> | 24 #include <windows.h> |
24 | 25 |
25 #include "base/file_version_info.h" | 26 #include "base/file_version_info.h" |
26 #include "base/win/registry.h" | 27 #include "base/win/registry.h" |
27 #include "chrome/installer/util/google_chrome_sxs_distribution.h" | 28 #include "chrome/installer/util/google_chrome_sxs_distribution.h" |
28 #include "chrome/installer/util/install_util.h" | 29 #include "chrome/installer/util/install_util.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 *version = PRODUCT_VERSION; | 272 *version = PRODUCT_VERSION; |
272 } | 273 } |
273 | 274 |
274 base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() { | 275 base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() { |
275 return base::FilePath(CrashUploadList::kReporterLogFilename); | 276 return base::FilePath(CrashUploadList::kReporterLogFilename); |
276 } | 277 } |
277 #endif | 278 #endif |
278 | 279 |
279 bool ChromeCrashReporterClient::GetCrashDumpLocation( | 280 bool ChromeCrashReporterClient::GetCrashDumpLocation( |
280 base::FilePath* crash_dir) { | 281 base::FilePath* crash_dir) { |
| 282 #if defined(OS_WIN) |
| 283 // In order to be able to start crash handling very early, we do not rely on |
| 284 // chrome's PathService entries (for DIR_CRASH_DUMPS) being available on |
| 285 // Windows. See https://crbug.com/564398. |
| 286 base::FilePath result; |
| 287 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &result)) |
| 288 return false; |
| 289 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 290 result = result.Append(dist->GetInstallSubDir()); |
| 291 // TODO(scottmg): Consider supporting --user-data-dir. See |
| 292 // https://crbug.com/565446. |
| 293 result = result.Append(chrome::kUserDataDirname); |
| 294 result = result.Append(FILE_PATH_LITERAL("Crashpad")); |
| 295 *crash_dir = result; |
| 296 return true; |
| 297 #else |
281 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 298 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
282 // location to write breakpad crash dumps can be set. | 299 // location to write breakpad crash dumps can be set. |
283 scoped_ptr<base::Environment> env(base::Environment::Create()); | 300 scoped_ptr<base::Environment> env(base::Environment::Create()); |
284 std::string alternate_crash_dump_location; | 301 std::string alternate_crash_dump_location; |
285 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { | 302 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { |
286 base::FilePath crash_dumps_dir_path = | 303 base::FilePath crash_dumps_dir_path = |
287 base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); | 304 base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); |
288 PathService::Override(chrome::DIR_CRASH_DUMPS, crash_dumps_dir_path); | 305 PathService::Override(chrome::DIR_CRASH_DUMPS, crash_dumps_dir_path); |
289 } | 306 } |
290 | 307 |
291 return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); | 308 return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); |
| 309 #endif |
292 } | 310 } |
293 | 311 |
294 size_t ChromeCrashReporterClient::RegisterCrashKeys() { | 312 size_t ChromeCrashReporterClient::RegisterCrashKeys() { |
295 return crash_keys::RegisterChromeCrashKeys(); | 313 return crash_keys::RegisterChromeCrashKeys(); |
296 } | 314 } |
297 | 315 |
298 bool ChromeCrashReporterClient::IsRunningUnattended() { | 316 bool ChromeCrashReporterClient::IsRunningUnattended() { |
299 scoped_ptr<base::Environment> env(base::Environment::Create()); | 317 scoped_ptr<base::Environment> env(base::Environment::Create()); |
300 return env->HasVar(env_vars::kHeadless); | 318 return env->HasVar(env_vars::kHeadless); |
301 } | 319 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 #endif | 353 #endif |
336 | 354 |
337 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 355 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
338 const std::string& process_type) { | 356 const std::string& process_type) { |
339 return process_type == switches::kRendererProcess || | 357 return process_type == switches::kRendererProcess || |
340 process_type == switches::kPluginProcess || | 358 process_type == switches::kPluginProcess || |
341 process_type == switches::kPpapiPluginProcess || | 359 process_type == switches::kPpapiPluginProcess || |
342 process_type == switches::kZygoteProcess || | 360 process_type == switches::kZygoteProcess || |
343 process_type == switches::kGpuProcess; | 361 process_type == switches::kGpuProcess; |
344 } | 362 } |
OLD | NEW |