| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/crash/content/app/crashpad.h" | 5 #include "components/crash/content/app/crashpad.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 (*annotations)["channel"] = base::UTF16ToUTF8(channel_name); | 45 (*annotations)["channel"] = base::UTF16ToUTF8(channel_name); |
| 46 if (!special_build.empty()) | 46 if (!special_build.empty()) |
| 47 (*annotations)["special"] = base::UTF16ToUTF8(special_build); | 47 (*annotations)["special"] = base::UTF16ToUTF8(special_build); |
| 48 #if defined(ARCH_CPU_X86) | 48 #if defined(ARCH_CPU_X86) |
| 49 (*annotations)["plat"] = std::string("Win32"); | 49 (*annotations)["plat"] = std::string("Win32"); |
| 50 #elif defined(ARCH_CPU_X86_64) | 50 #elif defined(ARCH_CPU_X86_64) |
| 51 (*annotations)["plat"] = std::string("Win64"); | 51 (*annotations)["plat"] = std::string("Win64"); |
| 52 #endif | 52 #endif |
| 53 } | 53 } |
| 54 | 54 |
| 55 base::FilePath PlatformCrashpadInitialization(bool initial_client, | 55 base::FilePath PlatformCrashpadInitialization( |
| 56 bool browser_process, | 56 bool initial_client, |
| 57 bool embedded_handler) { | 57 bool browser_process, |
| 58 bool embedded_handler, |
| 59 const std::string& user_data_dir) { |
| 58 base::FilePath database_path; // Only valid in the browser process. | 60 base::FilePath database_path; // Only valid in the browser process. |
| 59 base::FilePath metrics_path; // Only valid in the browser process. | 61 base::FilePath metrics_path; // Only valid in the browser process. |
| 60 | 62 |
| 61 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; | 63 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; |
| 62 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; | 64 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; |
| 63 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 65 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 64 if (initial_client) { | 66 if (initial_client) { |
| 65 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 67 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
| 66 | 68 |
| 67 base::string16 database_path_str; | 69 base::string16 database_path_str; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 crashpad::TriState::kEnabled, kIndirectMemoryLimit); | 102 crashpad::TriState::kEnabled, kIndirectMemoryLimit); |
| 101 } | 103 } |
| 102 | 104 |
| 103 // If the handler is embedded in the binary (e.g. chrome, setup), we | 105 // If the handler is embedded in the binary (e.g. chrome, setup), we |
| 104 // reinvoke it with --type=crashpad-handler. Otherwise, we use the | 106 // reinvoke it with --type=crashpad-handler. Otherwise, we use the |
| 105 // standalone crashpad_handler.exe (for tests, etc.). | 107 // standalone crashpad_handler.exe (for tests, etc.). |
| 106 std::vector<std::string> start_arguments; | 108 std::vector<std::string> start_arguments; |
| 107 if (embedded_handler) { | 109 if (embedded_handler) { |
| 108 start_arguments.push_back(std::string("--type=") + | 110 start_arguments.push_back(std::string("--type=") + |
| 109 switches::kCrashpadHandler); | 111 switches::kCrashpadHandler); |
| 112 if (!user_data_dir.empty()) { |
| 113 start_arguments.push_back(std::string("--user-data-dir=") + |
| 114 user_data_dir); |
| 115 } |
| 110 // The prefetch argument added here has to be documented in | 116 // The prefetch argument added here has to be documented in |
| 111 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant | 117 // chrome_switches.cc, below the kPrefetchArgument* constants. A constant |
| 112 // can't be used here because crashpad can't depend on Chrome. | 118 // can't be used here because crashpad can't depend on Chrome. |
| 113 start_arguments.push_back("/prefetch:7"); | 119 start_arguments.push_back("/prefetch:7"); |
| 114 } else { | 120 } else { |
| 115 base::FilePath exe_dir = exe_file.DirName(); | 121 base::FilePath exe_dir = exe_file.DirName(); |
| 116 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); | 122 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); |
| 117 } | 123 } |
| 118 | 124 |
| 119 std::vector<std::string> arguments(start_arguments); | 125 std::vector<std::string> arguments(start_arguments); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 362 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
| 357 void* start) { | 363 void* start) { |
| 358 ExceptionHandlerRecord* record = | 364 ExceptionHandlerRecord* record = |
| 359 reinterpret_cast<ExceptionHandlerRecord*>(start); | 365 reinterpret_cast<ExceptionHandlerRecord*>(start); |
| 360 | 366 |
| 361 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 367 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
| 362 } | 368 } |
| 363 #endif // ARCH_CPU_X86_64 | 369 #endif // ARCH_CPU_X86_64 |
| 364 | 370 |
| 365 } // extern "C" | 371 } // extern "C" |
| OLD | NEW |