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 #if BUILDFLAG(ENABLE_KASKO) | 10 #if BUILDFLAG(ENABLE_KASKO) |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 #elif defined(OS_WIN) | 257 #elif defined(OS_WIN) |
258 // On Windows, we want both the browser process and the installer and any | 258 // On Windows, we want both the browser process and the installer and any |
259 // other "main, first process" to initialize things. There is no "relauncher" | 259 // other "main, first process" to initialize things. There is no "relauncher" |
260 // on Windows, so this is synonymous with initial_client. | 260 // on Windows, so this is synonymous with initial_client. |
261 const bool should_initialize_database_and_set_upload_policy = initial_client; | 261 const bool should_initialize_database_and_set_upload_policy = initial_client; |
262 #endif | 262 #endif |
263 if (should_initialize_database_and_set_upload_policy) { | 263 if (should_initialize_database_and_set_upload_policy) { |
264 g_database = | 264 g_database = |
265 crashpad::CrashReportDatabase::Initialize(database_path).release(); | 265 crashpad::CrashReportDatabase::Initialize(database_path).release(); |
266 | 266 |
267 bool enable_uploads = false; | 267 UpdateUploadsEnabled(crash_reporter_client->GetCollectStatsConsent()); |
268 if (!crash_reporter_client->ReportingIsEnforcedByPolicy(&enable_uploads)) { | |
269 // Breakpad provided a --disable-breakpad switch to disable crash dumping | |
270 // (not just uploading) here. Crashpad doesn't need it: dumping is enabled | |
271 // unconditionally and uploading is gated on consent, which tests/bots | |
272 // shouldn't have. As a precaution, uploading is also disabled on bots | |
273 // even if consent is present. | |
274 enable_uploads = crash_reporter_client->GetCollectStatsConsent() && | |
275 !crash_reporter_client->IsRunningUnattended(); | |
276 } | |
277 | |
278 SetUploadsEnabled(enable_uploads); | |
279 } | 268 } |
280 } | 269 } |
281 | 270 |
282 } // namespace | 271 } // namespace |
283 | 272 |
284 void InitializeCrashpad(bool initial_client, const std::string& process_type) { | 273 void InitializeCrashpad(bool initial_client, const std::string& process_type) { |
285 InitializeCrashpadImpl(initial_client, process_type, false); | 274 InitializeCrashpadImpl(initial_client, process_type, false); |
286 } | 275 } |
287 | 276 |
288 #if defined(OS_WIN) | 277 #if defined(OS_WIN) |
289 void InitializeCrashpadWithEmbeddedHandler(bool initial_client, | 278 void InitializeCrashpadWithEmbeddedHandler(bool initial_client, |
290 const std::string& process_type) { | 279 const std::string& process_type) { |
291 InitializeCrashpadImpl(initial_client, process_type, true); | 280 InitializeCrashpadImpl(initial_client, process_type, true); |
292 } | 281 } |
293 #endif // OS_WIN | 282 #endif // OS_WIN |
294 | 283 |
295 void SetUploadsEnabled(bool enable_uploads) { | 284 void UpdateUploadsEnabled(bool consent) { |
296 if (g_database) { | 285 if (g_database) { |
Alexei Svitkine (slow)
2016/08/17 20:37:48
Nit: Early return instead.
jwd
2016/08/17 21:55:59
Done.
| |
286 bool enable_uploads = false; | |
287 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | |
288 if (!crash_reporter_client->ReportingIsEnforcedByPolicy(&enable_uploads)) { | |
289 // Breakpad provided a --disable-breakpad switch to disable crash | |
Mark Mentovai
2016/08/17 20:59:07
What’s up with this indentation?
jwd
2016/08/17 21:55:59
Done.
| |
290 // dumping (not just uploading) here. Crashpad doesn't need it: dumping | |
291 // is enabled unconditionally and uploading is gated on consent, which | |
292 // tests/bots shouldn't have. As a precaution, uploading is also | |
293 // disabled on bots even if consent is present. | |
294 enable_uploads = consent && | |
295 !crash_reporter_client->IsRunningUnattended(); | |
296 } | |
Alexei Svitkine (slow)
2016/08/17 20:37:48
Nit: Indent is off. Run git cl format.
jwd
2016/08/17 21:55:59
Done.
| |
297 | |
298 | |
Alexei Svitkine (slow)
2016/08/17 20:37:48
Nit: Remove extra blank line.
jwd
2016/08/17 21:55:59
Done.
| |
297 crashpad::Settings* settings = g_database->GetSettings(); | 299 crashpad::Settings* settings = g_database->GetSettings(); |
298 settings->SetUploadsEnabled(enable_uploads); | 300 settings->SetUploadsEnabled( |
301 enable_uploads && crash_reporter_client->GetCollectStatsInSample()); | |
299 } | 302 } |
300 } | 303 } |
301 | 304 |
302 bool GetUploadsEnabled() { | 305 bool GetUploadsEnabled() { |
303 if (g_database) { | 306 if (g_database) { |
304 crashpad::Settings* settings = g_database->GetSettings(); | 307 crashpad::Settings* settings = g_database->GetSettings(); |
305 bool enable_uploads; | 308 bool enable_uploads; |
306 if (settings->GetUploadsEnabled(&enable_uploads)) { | 309 if (settings->GetUploadsEnabled(&enable_uploads)) { |
307 return enable_uploads; | 310 return enable_uploads; |
308 } | 311 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 } | 456 } |
454 | 457 |
455 #endif // BUILDFLAG(ENABLE_KASKO) | 458 #endif // BUILDFLAG(ENABLE_KASKO) |
456 | 459 |
457 } // namespace crash_reporter | 460 } // namespace crash_reporter |
458 | 461 |
459 #if defined(OS_WIN) | 462 #if defined(OS_WIN) |
460 | 463 |
461 extern "C" { | 464 extern "C" { |
462 | 465 |
466 // This function is used in chrome_metrics_services_manager_client.cc to trigger | |
467 // changes to the upload-enabled state. This is done when the metrics services | |
468 // are initialized, and when the user changes their consent for uploads. See | |
469 // crash_reporter::UpdateUploadsEnabled for effects. | |
470 void __declspec(dllexport) __cdecl UpdateUploadsEnabledImpl(bool consent) { | |
471 crash_reporter::UpdateUploadsEnabled(consent); | |
472 } | |
473 | |
463 // NOTE: This function is used by SyzyASAN to annotate crash reports. If you | 474 // NOTE: This function is used by SyzyASAN to annotate crash reports. If you |
464 // change the name or signature of this function you will break SyzyASAN | 475 // change the name or signature of this function you will break SyzyASAN |
465 // instrumented releases of Chrome. Please contact syzygy-team@chromium.org | 476 // instrumented releases of Chrome. Please contact syzygy-team@chromium.org |
466 // before doing so! See also http://crbug.com/567781. | 477 // before doing so! See also http://crbug.com/567781. |
467 void __declspec(dllexport) __cdecl SetCrashKeyValueImpl(const wchar_t* key, | 478 void __declspec(dllexport) __cdecl SetCrashKeyValueImpl(const wchar_t* key, |
468 const wchar_t* value) { | 479 const wchar_t* value) { |
469 crash_reporter::SetCrashKeyValue(base::UTF16ToUTF8(key), | 480 crash_reporter::SetCrashKeyValue(base::UTF16ToUTF8(key), |
470 base::UTF16ToUTF8(value)); | 481 base::UTF16ToUTF8(value)); |
471 } | 482 } |
472 | 483 |
473 void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl(const wchar_t* key) { | 484 void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl(const wchar_t* key) { |
474 crash_reporter::ClearCrashKey(base::UTF16ToUTF8(key)); | 485 crash_reporter::ClearCrashKey(base::UTF16ToUTF8(key)); |
475 } | 486 } |
476 | 487 |
477 } // extern "C" | 488 } // extern "C" |
478 | 489 |
479 #endif // OS_WIN | 490 #endif // OS_WIN |
OLD | NEW |