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

Unified Diff: chrome/app/breakpad_win.cc

Issue 11776040: Add Windows implementation for base/debug/crash_logging.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 7 years, 11 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 | « no previous file | chrome/chrome_exe.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/breakpad_win.cc
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index d141b7cfa12e7147eb08d083bc5cebce560cb1f8..e97cf5847313730ad83f9c7ca80404edff8843aa 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -14,6 +14,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
+#include "base/debug/crash_logging.h"
#include "base/environment.h"
#include "base/file_util.h"
#include "base/file_version_info.h"
@@ -32,6 +33,7 @@
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/crash_keys.h"
#include "chrome/common/env_vars.h"
#include "chrome/installer/util/google_chrome_sxs_distribution.h"
#include "chrome/installer/util/google_update_settings.h"
@@ -103,6 +105,10 @@ static size_t g_printer_info_offset = 0;
static size_t g_num_of_views_offset = 0;
static size_t g_num_switches_offset = 0;
static size_t g_switches_offset = 0;
+static size_t g_dynamic_keys_offset = 0;
+typedef std::map<std::string, google_breakpad::CustomInfoEntry*>
+ DynamicEntriesMap;
+DynamicEntriesMap* g_dynamic_entries = NULL;
Scott Hess - ex-Googler 2013/01/16 22:45:28 I went to look if the key could be a string piece
// Maximum length for plugin path to include in plugin crash reports.
const size_t kMaxPluginPathLength = 256;
@@ -464,6 +470,15 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path,
base::StringPrintf(L"experiment-chunk-%i", i).c_str(), L""));
}
+ // Create space for dynamic ad-hoc keys. The names and values are set using
+ // the API defined in base/debug/crash_logging.h.
+ size_t num_custom_keys = crash_keys::RegisterChromeCrashKeys();
+ g_dynamic_keys_offset = g_custom_entries->size();
+ for (size_t i = 0; i < num_custom_keys; ++i) {
+ g_custom_entries->push_back(google_breakpad::CustomInfoEntry());
+ }
+ g_dynamic_entries = new DynamicEntriesMap;
+
static google_breakpad::CustomClientInfo custom_client_info;
custom_client_info.entries = &g_custom_entries->front();
custom_client_info.count = g_custom_entries->size();
@@ -665,6 +680,30 @@ extern "C" void __declspec(dllexport) __cdecl SetNumberOfViews(
SetIntegerValue(g_num_of_views_offset, number_of_views);
}
+void SetCrashKeyValue(const base::StringPiece& key,
+ const base::StringPiece& value) {
+ std::string key_string = key.as_string();
+
+ DynamicEntriesMap::iterator it = g_dynamic_entries->find(key_string);
+ google_breakpad::CustomInfoEntry* entry = NULL;
+ if (it == g_dynamic_entries->end()) {
+ entry = &(*g_custom_entries)[g_dynamic_keys_offset++];
Scott Hess - ex-Googler 2013/01/16 22:45:28 Seems like this might want some sort of range chec
Robert Sesek 2013/01/17 19:39:10 Done.
+ g_dynamic_entries->insert(std::make_pair(key_string, entry));
+ } else {
+ entry = it->second;
+ }
+
+ entry->set(UTF8ToWide(key).data(), UTF8ToWide(value).data());
+}
+
+void ClearCrashKeyValue(const base::StringPiece& key) {
+ DynamicEntriesMap::iterator it = g_dynamic_entries->find(key.as_string());
+ if (it == g_dynamic_entries->end())
+ return;
+
+ it->second->set(NULL, NULL);
+}
+
} // namespace
namespace testing {
@@ -866,8 +905,11 @@ void InitCrashReporter() {
GoogleUpdateSettings::GetChromeChannelAndModifiers(!is_per_user_install,
&channel_string);
+ base::debug::SetCrashKeyReportingFunctions(
+ &SetCrashKeyValue, &ClearCrashKeyValue);
+
google_breakpad::CustomClientInfo* custom_info =
- GetCustomInfo(exe_path, process_type, channel_string);
+ GetCustomInfo(exe_path, process_type, channel_string);
google_breakpad::ExceptionHandler::MinidumpCallback callback = NULL;
LPTOP_LEVEL_EXCEPTION_FILTER default_filter = NULL;
« no previous file with comments | « no previous file | chrome/chrome_exe.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698