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..475aeef47328620ef1cf4aec561dacd11c8d86d0 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(chrome::kChromeElfDllName); |
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(chrome::kChromeElfDllName); |
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 |
+ // 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); |
+ |
+ // Set the client id in chrome_elf if it is loaded. We should not be |
+ // registering crash keys in this case as that would already have been |
+ // done by chrome_elf. |
+ HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); |
+ if (elf_module) { |
+ using SetMetricsClientIdFunction = void (*)(const char* client_id); |
+ SetMetricsClientIdFunction set_metrics_id_fn = |
+ reinterpret_cast<SetMetricsClientIdFunction>( |
+ ::GetProcAddress(elf_module, "SetMetricsClientId")); |
+ DCHECK(set_metrics_id_fn); |
+ set_metrics_id_fn(client_info ? client_info->client_id.c_str() : nullptr); |
sky
2016/06/28 02:40:45
Does SetMetricsClientId make a copy of the char*?
ananta
2016/06/28 03:15:43
Yes. It eventually ends up here. https://cs.chromi
|
+ } else { |
+ // TODO(ananta) |
+ // Remove this when the change to not require crash key registration lands. |
+ crash_keys::RegisterChromeCrashKeys(); |
+ if (client_info) |
+ crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); |
+ } |
+ |
+ base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline, |
+ &ClearCrashKeyValueTrampoline); |
} |
} // namespace child_process_logging |