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

Unified Diff: chrome/common/crash_keys.cc

Issue 23604061: Set the printer info in crash reports using the crash key logging system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory issue Created 7 years, 3 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 | « chrome/common/crash_keys.h ('k') | chrome/service/cloud_print/print_system_cups.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/crash_keys.cc
diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc
index 7a3e6ecf90dd84570534c6249c32c5fa7c51fa16..34c680b6d00af34fb5d853f1f11e2aa4c0bc71ef 100644
--- a/chrome/common/crash_keys.cc
+++ b/chrome/common/crash_keys.cc
@@ -6,6 +6,7 @@
#include "base/format_macros.h"
#include "base/logging.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -71,6 +72,8 @@ const char kGPURenderer[] = "gpu-gl-renderer";
const char kGPUGLVersion[] = "gpu-glver";
#endif
+const char kPrinterInfo[] = "prn-info-%" PRIuS;
+
#if defined(OS_MACOSX)
namespace mac {
@@ -160,6 +163,21 @@ size_t RegisterChromeCrashKeys() {
}
}
+ // Register the printer info.
+ {
+ static char formatted_keys[kPrinterInfoCount][sizeof(kPrinterInfo) + 1] =
+ {{ 0 }};
+ const size_t formatted_key_len = sizeof(formatted_keys[0]);
+ for (size_t i = 0; i < kPrinterInfoCount; ++i) {
+ // Key names are 1-indexed.
+ int n = base::snprintf(
+ formatted_keys[i], formatted_key_len, kPrinterInfo, i + 1);
+ DCHECK_GT(n, 0);
+ base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize };
+ keys.push_back(crash_key);
+ }
+ }
+
return base::debug::InitCrashKeys(&keys.at(0), keys.size(),
kSingleChunkLength);
}
@@ -180,4 +198,23 @@ void SetActiveExtensions(const std::set<std::string>& extensions) {
}
}
+ScopedPrinterInfo::ScopedPrinterInfo(const base::StringPiece& data) {
+ std::vector<std::string> info;
+ base::SplitString(data.as_string(), ';', &info);
+ for (size_t i = 0; i < kPrinterInfoCount; ++i) {
+ std::string key = base::StringPrintf(kPrinterInfo, i + 1);
+ std::string value;
+ if (i < info.size())
+ value = info[i];
+ base::debug::SetCrashKeyValue(key, value);
+ }
+}
+
+ScopedPrinterInfo::~ScopedPrinterInfo() {
+ for (size_t i = 0; i < kPrinterInfoCount; ++i) {
+ std::string key = base::StringPrintf(kPrinterInfo, i + 1);
+ base::debug::ClearCrashKey(key);
+ }
+}
+
} // namespace crash_keys
« no previous file with comments | « chrome/common/crash_keys.h ('k') | chrome/service/cloud_print/print_system_cups.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698