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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 const bool should_initialize_database_and_set_upload_policy = initial_client; | 185 const bool should_initialize_database_and_set_upload_policy = initial_client; |
185 #endif | 186 #endif |
186 if (should_initialize_database_and_set_upload_policy) { | 187 if (should_initialize_database_and_set_upload_policy) { |
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 |
195 void InitializeCrashpadImpl(bool initial_client, | |
196 const std::string& process_type, | |
197 bool embedded_handler) { | |
198 InitializeCrashpadImpl(initial_client, process_type, std::string(), | |
199 embedded_handler); | |
Sigurður Ásgeirsson
2017/05/11 15:33:40
seems strange to use an overload to pad this argum
manzagop (departed)
2017/05/11 19:14:54
Done.
| |
200 } | |
201 | |
194 } // namespace | 202 } // namespace |
195 | 203 |
196 void InitializeCrashpad(bool initial_client, const std::string& process_type) { | 204 void InitializeCrashpad(bool initial_client, const std::string& process_type) { |
197 InitializeCrashpadImpl(initial_client, process_type, false); | 205 InitializeCrashpadImpl(initial_client, process_type, false); |
198 } | 206 } |
199 | 207 |
200 #if defined(OS_WIN) | 208 #if defined(OS_WIN) |
201 void InitializeCrashpadWithEmbeddedHandler(bool initial_client, | 209 void InitializeCrashpadWithEmbeddedHandler(bool initial_client, |
202 const std::string& process_type) { | 210 const std::string& process_type, |
203 InitializeCrashpadImpl(initial_client, process_type, true); | 211 const std::string& user_data_dir) { |
212 InitializeCrashpadImpl(initial_client, process_type, user_data_dir, true); | |
204 } | 213 } |
205 #endif // OS_WIN | 214 #endif // OS_WIN |
206 | 215 |
207 crashpad::CrashpadClient& GetCrashpadClient() { | 216 crashpad::CrashpadClient& GetCrashpadClient() { |
208 static crashpad::CrashpadClient* const client = | 217 static crashpad::CrashpadClient* const client = |
209 new crashpad::CrashpadClient(); | 218 new crashpad::CrashpadClient(); |
210 return *client; | 219 return *client; |
211 } | 220 } |
212 | 221 |
213 void SetUploadConsent(bool consent) { | 222 void SetUploadConsent(bool consent) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 | 346 |
338 // This helper is invoked by code in chrome.dll to request a single crash report | 347 // This helper is invoked by code in chrome.dll to request a single crash report |
339 // upload. See CrashUploadListCrashpad. | 348 // upload. See CrashUploadListCrashpad. |
340 void __declspec(dllexport) | 349 void __declspec(dllexport) |
341 RequestSingleCrashUploadImpl(const std::string& local_id) { | 350 RequestSingleCrashUploadImpl(const std::string& local_id) { |
342 crash_reporter::RequestSingleCrashUpload(local_id); | 351 crash_reporter::RequestSingleCrashUpload(local_id); |
343 } | 352 } |
344 } // extern "C" | 353 } // extern "C" |
345 | 354 |
346 #endif // OS_WIN | 355 #endif // OS_WIN |
OLD | NEW |