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 <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // do it. | 89 // do it. |
90 return false; | 90 return false; |
91 } | 91 } |
92 | 92 |
93 void DumpWithoutCrashing() { | 93 void DumpWithoutCrashing() { |
94 CRASHPAD_SIMULATE_CRASH(); | 94 CRASHPAD_SIMULATE_CRASH(); |
95 } | 95 } |
96 | 96 |
97 void InitializeCrashpadImpl(bool initial_client, | 97 void InitializeCrashpadImpl(bool initial_client, |
98 const std::string& process_type, | 98 const std::string& process_type, |
| 99 const std::string& user_data_dir, |
99 bool embedded_handler) { | 100 bool embedded_handler) { |
100 static bool initialized = false; | 101 static bool initialized = false; |
101 DCHECK(!initialized); | 102 DCHECK(!initialized); |
102 initialized = true; | 103 initialized = true; |
103 | 104 |
104 const bool browser_process = process_type.empty(); | 105 const bool browser_process = process_type.empty(); |
105 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 106 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
106 | 107 |
107 if (initial_client) { | 108 if (initial_client) { |
108 #if defined(OS_MACOSX) | 109 #if defined(OS_MACOSX) |
109 // "relauncher" is hard-coded because it's a Chrome --type, but this | 110 // "relauncher" is hard-coded because it's a Chrome --type, but this |
110 // component can't see Chrome's switches. This is only used for argument | 111 // component can't see Chrome's switches. This is only used for argument |
111 // sanitization. | 112 // sanitization. |
112 DCHECK(browser_process || process_type == "relauncher"); | 113 DCHECK(browser_process || process_type == "relauncher"); |
113 #elif defined(OS_WIN) | 114 #elif defined(OS_WIN) |
114 // "Chrome Installer" is the name historically used for installer binaries | 115 // "Chrome Installer" is the name historically used for installer binaries |
115 // as processed by the backend. | 116 // as processed by the backend. |
116 DCHECK(browser_process || process_type == "Chrome Installer"); | 117 DCHECK(browser_process || process_type == "Chrome Installer"); |
117 #else | 118 #else |
118 #error Port. | 119 #error Port. |
119 #endif // OS_MACOSX | 120 #endif // OS_MACOSX |
120 } else { | 121 } else { |
121 DCHECK(!browser_process); | 122 DCHECK(!browser_process); |
122 } | 123 } |
123 | 124 |
124 // database_path is only valid in the browser process. | 125 // database_path is only valid in the browser process. |
125 base::FilePath database_path = internal::PlatformCrashpadInitialization( | 126 base::FilePath database_path = internal::PlatformCrashpadInitialization( |
126 initial_client, browser_process, embedded_handler); | 127 initial_client, browser_process, embedded_handler, user_data_dir); |
127 | 128 |
128 crashpad::CrashpadInfo* crashpad_info = | 129 crashpad::CrashpadInfo* crashpad_info = |
129 crashpad::CrashpadInfo::GetCrashpadInfo(); | 130 crashpad::CrashpadInfo::GetCrashpadInfo(); |
130 | 131 |
131 #if defined(OS_MACOSX) | 132 #if defined(OS_MACOSX) |
132 #if defined(NDEBUG) | 133 #if defined(NDEBUG) |
133 const bool is_debug_build = false; | 134 const bool is_debug_build = false; |
134 #else | 135 #else |
135 const bool is_debug_build = true; | 136 const bool is_debug_build = true; |
136 #endif | 137 #endif |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 g_database = | 188 g_database = |
188 crashpad::CrashReportDatabase::Initialize(database_path).release(); | 189 crashpad::CrashReportDatabase::Initialize(database_path).release(); |
189 | 190 |
190 SetUploadConsent(crash_reporter_client->GetCollectStatsConsent()); | 191 SetUploadConsent(crash_reporter_client->GetCollectStatsConsent()); |
191 } | 192 } |
192 } | 193 } |
193 | 194 |
194 } // namespace | 195 } // namespace |
195 | 196 |
196 void InitializeCrashpad(bool initial_client, const std::string& process_type) { | 197 void InitializeCrashpad(bool initial_client, const std::string& process_type) { |
197 InitializeCrashpadImpl(initial_client, process_type, false); | 198 InitializeCrashpadImpl(initial_client, process_type, std::string(), false); |
198 } | 199 } |
199 | 200 |
200 #if defined(OS_WIN) | 201 #if defined(OS_WIN) |
201 void InitializeCrashpadWithEmbeddedHandler(bool initial_client, | 202 void InitializeCrashpadWithEmbeddedHandler(bool initial_client, |
202 const std::string& process_type) { | 203 const std::string& process_type, |
203 InitializeCrashpadImpl(initial_client, process_type, true); | 204 const std::string& user_data_dir) { |
| 205 InitializeCrashpadImpl(initial_client, process_type, user_data_dir, true); |
204 } | 206 } |
205 #endif // OS_WIN | 207 #endif // OS_WIN |
206 | 208 |
207 crashpad::CrashpadClient& GetCrashpadClient() { | 209 crashpad::CrashpadClient& GetCrashpadClient() { |
208 static crashpad::CrashpadClient* const client = | 210 static crashpad::CrashpadClient* const client = |
209 new crashpad::CrashpadClient(); | 211 new crashpad::CrashpadClient(); |
210 return *client; | 212 return *client; |
211 } | 213 } |
212 | 214 |
213 void SetUploadConsent(bool consent) { | 215 void SetUploadConsent(bool consent) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 339 |
338 // This helper is invoked by code in chrome.dll to request a single crash report | 340 // This helper is invoked by code in chrome.dll to request a single crash report |
339 // upload. See CrashUploadListCrashpad. | 341 // upload. See CrashUploadListCrashpad. |
340 void __declspec(dllexport) | 342 void __declspec(dllexport) |
341 RequestSingleCrashUploadImpl(const std::string& local_id) { | 343 RequestSingleCrashUploadImpl(const std::string& local_id) { |
342 crash_reporter::RequestSingleCrashUpload(local_id); | 344 crash_reporter::RequestSingleCrashUpload(local_id); |
343 } | 345 } |
344 } // extern "C" | 346 } // extern "C" |
345 | 347 |
346 #endif // OS_WIN | 348 #endif // OS_WIN |
OLD | NEW |