Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1787)

Unified Diff: base/debug/crash_logging.cc

Issue 2708883006: Add possibility to ignore unregistered crash keys. Use this from WebView (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/crash_logging.h ('k') | base/debug/crash_logging_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/crash_logging.cc
diff --git a/base/debug/crash_logging.cc b/base/debug/crash_logging.cc
index 32b6b05e3967312b729ec4193cb5ef960ad75097..b7b65396410be619039968fe7b41a886431e77e5 100644
--- a/base/debug/crash_logging.cc
+++ b/base/debug/crash_logging.cc
@@ -32,6 +32,8 @@ size_t g_chunk_max_length_ = 0;
// String used to format chunked key names.
const char kChunkFormatString[] = "%s-%" PRIuS;
+bool g_ignore_unregistered_keys_ = false;
+
// The functions that are called to actually set the key-value pairs in the
// crash reportng system.
SetCrashKeyValueFuncT g_set_key_func_ = NULL;
@@ -56,6 +58,10 @@ void SetCrashKeyValue(const base::StringPiece& key,
const CrashKey* crash_key = LookupCrashKey(key);
+ if (g_ignore_unregistered_keys_ && !crash_key) {
+ return;
+ }
+
DCHECK(crash_key) << "All crash keys must be registered before use "
<< "(key = " << key << ")";
@@ -144,7 +150,16 @@ ScopedCrashKey::~ScopedCrashKey() {
size_t InitCrashKeys(const CrashKey* const keys, size_t count,
size_t chunk_max_length) {
+ return InitCrashKeys(keys, count, chunk_max_length,
+ false /* ignore_unregistered_keys */);
+}
+
+size_t InitCrashKeys(const CrashKey* const keys,
+ size_t count,
+ size_t chunk_max_length,
+ bool ignore_unregistered_keys) {
DCHECK(!g_crash_keys_) << "Crash logging may only be initialized once";
+ g_ignore_unregistered_keys_ = ignore_unregistered_keys;
if (!keys) {
delete g_crash_keys_;
g_crash_keys_ = NULL;
@@ -201,6 +216,7 @@ void ResetCrashLoggingForTesting() {
g_chunk_max_length_ = 0;
g_set_key_func_ = NULL;
g_clear_key_func_ = NULL;
+ g_ignore_unregistered_keys_ = false;
}
} // namespace debug
« no previous file with comments | « base/debug/crash_logging.h ('k') | base/debug/crash_logging_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698