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 "base/base_paths_win.h" |
7 #include "base/environment.h" | 8 #include "base/environment.h" |
8 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
11 #include "base/path_service.h" | |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "components/crash/content/app/crash_reporter_client.h" | 16 #include "components/crash/content/app/crash_reporter_client.h" |
17 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 17 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
18 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 18 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
19 | 19 |
20 namespace crash_reporter { | 20 namespace crash_reporter { |
21 namespace internal { | 21 namespace internal { |
(...skipping 13 matching lines...) Expand all Loading... |
35 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; | 35 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; |
36 scoped_ptr<base::Environment> env(base::Environment::Create()); | 36 scoped_ptr<base::Environment> env(base::Environment::Create()); |
37 | 37 |
38 DCHECK_EQ(initial_client, browser_process); | 38 DCHECK_EQ(initial_client, browser_process); |
39 | 39 |
40 if (initial_client) { | 40 if (initial_client) { |
41 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 41 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
42 crash_reporter_client->GetCrashDumpLocation(&database_path); | 42 crash_reporter_client->GetCrashDumpLocation(&database_path); |
43 | 43 |
44 base::FilePath exe_file; | 44 base::FilePath exe_file; |
45 CHECK(PathService::Get(base::FILE_EXE, &exe_file)); | 45 CHECK(GetFileExe(&exe_file)); |
46 base::string16 product_name, version, special_build, channel_name; | 46 base::string16 product_name, version, special_build, channel_name; |
47 crash_reporter_client->GetProductNameAndVersion( | 47 crash_reporter_client->GetProductNameAndVersion( |
48 exe_file, &product_name, &version, &special_build, &channel_name); | 48 exe_file, &product_name, &version, &special_build, &channel_name); |
49 std::map<std::string, std::string> process_annotations; | 49 std::map<std::string, std::string> process_annotations; |
50 process_annotations["prod"] = base::UTF16ToUTF8(product_name); | 50 process_annotations["prod"] = base::UTF16ToUTF8(product_name); |
51 process_annotations["ver"] = base::UTF16ToUTF8(version); | 51 process_annotations["ver"] = base::UTF16ToUTF8(version); |
52 process_annotations["channel"] = base::UTF16ToUTF8(channel_name); | 52 process_annotations["channel"] = base::UTF16ToUTF8(channel_name); |
53 if (!special_build.empty()) | 53 if (!special_build.empty()) |
54 process_annotations["special"] = base::UTF16ToUTF8(special_build); | 54 process_annotations["special"] = base::UTF16ToUTF8(special_build); |
55 #if defined(ARCH_CPU_X86) | 55 #if defined(ARCH_CPU_X86) |
56 process_annotations["plat"] = std::string("Win32"); | 56 process_annotations["plat"] = std::string("Win32"); |
57 #elif defined(ARCH_CPU_X86_64) | 57 #elif defined(ARCH_CPU_X86_64) |
58 process_annotations["plat"] = std::string("Win64"); | 58 process_annotations["plat"] = std::string("Win64"); |
59 #endif | 59 #endif |
60 #if defined(GOOGLE_CHROME_BUILD) | 60 #if defined(GOOGLE_CHROME_BUILD) |
61 std::string url = "https://clients2.google.com/cr/report"; | 61 std::string url = "https://clients2.google.com/cr/report"; |
62 #else | 62 #else |
63 std::string url; | 63 std::string url; |
64 #endif | 64 #endif |
65 | 65 |
66 std::vector<std::string> arguments; | 66 std::vector<std::string> arguments; |
67 | 67 |
68 // In test binaries, use crashpad_handler directly. Otherwise, we launch | 68 // In test binaries, use crashpad_handler directly. Otherwise, we launch |
69 // chrome.exe with --type=crashpad-handler. | 69 // chrome.exe with --type=crashpad-handler. |
70 if (exe_file.BaseName().value() != FILE_PATH_LITERAL("chrome.exe")) { | 70 if (exe_file.BaseName().value() != FILE_PATH_LITERAL("chrome.exe")) { |
71 base::FilePath exe_dir; | 71 base::FilePath exe_dir = exe_file.DirName(); |
72 CHECK(PathService::Get(base::DIR_EXE, &exe_dir)); | |
73 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); | 72 exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe")); |
74 } else { | 73 } else { |
75 arguments.push_back("--type=crashpad-handler"); | 74 arguments.push_back("--type=crashpad-handler"); |
76 } | 75 } |
77 | 76 |
78 result = g_crashpad_client.Get().StartHandler( | 77 result = g_crashpad_client.Get().StartHandler( |
79 exe_file, database_path, url, process_annotations, arguments, false); | 78 exe_file, database_path, url, process_annotations, arguments, false); |
80 | 79 |
81 // If we're the browser, push the pipe name into the environment so child | 80 // If we're the browser, push the pipe name into the environment so child |
82 // processes can connect to it. If we inherited another crashpad_handler's | 81 // processes can connect to it. If we inherited another crashpad_handler's |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 reinterpret_cast<ExceptionHandlerRecord*>(start); | 192 reinterpret_cast<ExceptionHandlerRecord*>(start); |
194 | 193 |
195 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 194 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
196 } | 195 } |
197 #endif // ARCH_CPU_X86_64 | 196 #endif // ARCH_CPU_X86_64 |
198 | 197 |
199 } // extern "C" | 198 } // extern "C" |
200 | 199 |
201 } // namespace internal | 200 } // namespace internal |
202 } // namespace crash_reporter | 201 } // namespace crash_reporter |
OLD | NEW |