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

Unified Diff: chrome/common/child_process_logging_win.cc

Issue 2088133002: Switch chrome_elf exception handling from breakpad to crashpad. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register crash keys only once in the process. Created 4 years, 6 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
Index: chrome/common/child_process_logging_win.cc
diff --git a/chrome/common/child_process_logging_win.cc b/chrome/common/child_process_logging_win.cc
index 3963bc3cc2eefd5c6e74ed5c4883d453c91ff7ee..94d947a18eef256ad2026e2cb59fc6616d93122e 100644
--- a/chrome/common/child_process_logging_win.cc
+++ b/chrome/common/child_process_logging_win.cc
@@ -29,10 +29,10 @@ typedef void(__cdecl* ClearCrashKeyValue)(const wchar_t*);
void SetCrashKeyValueTrampoline(const base::StringPiece& key,
const base::StringPiece& value) {
- static SetCrashKeyValue set_crash_key = [](){
- HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
+ static SetCrashKeyValue set_crash_key = []() {
+ HMODULE elf_module = GetModuleHandle(L"chrome_elf.dll");
return reinterpret_cast<SetCrashKeyValue>(
- exe_module ? GetProcAddress(exe_module, "SetCrashKeyValueImpl")
+ elf_module ? GetProcAddress(elf_module, "SetCrashKeyValueImpl")
: nullptr);
}();
if (set_crash_key) {
@@ -42,10 +42,10 @@ void SetCrashKeyValueTrampoline(const base::StringPiece& key,
}
void ClearCrashKeyValueTrampoline(const base::StringPiece& key) {
- static ClearCrashKeyValue clear_crash_key = [](){
- HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
+ static ClearCrashKeyValue clear_crash_key = []() {
+ HMODULE elf_module = GetModuleHandle(L"chrome_elf.dll");
return reinterpret_cast<ClearCrashKeyValue>(
- exe_module ? GetProcAddress(exe_module, "ClearCrashKeyValueImpl")
+ elf_module ? GetProcAddress(elf_module, "ClearCrashKeyValueImpl")
: nullptr);
}();
if (clear_crash_key)
@@ -55,18 +55,36 @@ void ClearCrashKeyValueTrampoline(const base::StringPiece& key) {
} // namespace
void Init() {
- crash_keys::RegisterChromeCrashKeys();
- base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline,
- &ClearCrashKeyValueTrampoline);
-
// This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but
// because of the aforementioned issue, crash keys aren't ready yet at the
// time of Breakpad initialization, load the client id backed up in Google
// Update settings instead.
+ // Please note if we are using CrashPad via chrome_elf then we need to call
scottmg 2016/06/27 19:37:46 nit; CrashPad -> Crashpad
ananta 2016/06/27 20:00:26 Done.
+ // into chrome_elf to pass in the client id.
std::unique_ptr<metrics::ClientInfo> client_info =
GoogleUpdateSettings::LoadMetricsClientInfo();
- if (client_info)
- crash_keys::SetMetricsClientIdFromGUID(client_info->client_id);
+
+ // Register crash keys using chrome_elf if it is loaded. This is because
+ // chrome_elf and chrome and other executables have their own copies of
+ // base.
+ // TODO(ananta)
+ // Remove this when the change to not require crash key registration lands.
+ HMODULE elf_module = GetModuleHandle(L"chrome_elf.dll");
+ if (elf_module) {
+ using RegisterCrashKeysFunction = void (*)(const char* client_id);
+ RegisterCrashKeysFunction register_keys_fn =
+ reinterpret_cast<RegisterCrashKeysFunction>(
+ ::GetProcAddress(elf_module, "RegisterCrashKeysImpl"));
+ DCHECK(register_keys_fn);
+ register_keys_fn(client_info ? client_info->client_id.c_str() : nullptr);
+ } else {
+ crash_keys::RegisterChromeCrashKeys();
scottmg 2016/06/27 20:09:24 I'm confused now, when is the non-elf path going t
+ if (client_info)
scottmg 2016/06/27 19:37:46 This should be out of the if/else I think?
ananta 2016/06/27 20:00:26 No. If exception handling is being done by chrome_
scottmg 2016/06/27 20:09:24 Ah, OK. Let's call RegisterCrashKeysImpl something
ananta 2016/06/27 20:36:05 Done.
+ crash_keys::SetMetricsClientIdFromGUID(client_info->client_id);
+ }
+
+ base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline,
+ &ClearCrashKeyValueTrampoline);
}
} // namespace child_process_logging

Powered by Google App Engine
This is Rietveld 408576698