Commit 320aa651 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Eliminate the remaining manual chrome_elf thunk.

Bug: 753363
Cq-Include-Trybots: master.tryserver.chromium.win:win10_chromium_x64_rel_ng
Change-Id: Ic9045893035329b8434fd8ca7fe18735c57f842c
Reviewed-on: https://chromium-review.googlesource.com/684874Reviewed-by: default avatarRobert Shield <robertshield@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504452}
parent f3d94c20
......@@ -436,6 +436,7 @@ static_library("common") {
if (is_win) {
deps = [
"//chrome/common/win:eventlog_messages",
"//chrome_elf:chrome_elf_main_include",
"//components/crash/content/app:crash_export_thunk_include",
]
......
include_rules = [
"+chrome/grit",
"+chrome/install_static",
"+chrome_elf/chrome_elf_main.h",
"+chromeos", # For chromeos_switches.h
"+components/autofill/content/common",
"+components/autofill/core/common",
......
......@@ -13,6 +13,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/crash_keys.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome_elf/chrome_elf_main.h"
#include "components/crash/content/app/crash_export_thunks.h"
#include "components/metrics/client_info.h"
......@@ -35,7 +36,6 @@ void ClearCrashKeyValueTrampoline(const base::StringPiece& key) {
void Init() {
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
......@@ -45,34 +45,12 @@ void Init() {
std::unique_ptr<metrics::ClientInfo> client_info =
GoogleUpdateSettings::LoadMetricsClientInfo();
// 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) {
// TODO(ananta)
// Remove this when the change to not require crash key registration lands.
// Please note that we are registering the crash keys twice if chrome_elf is
// loaded. Once in chrome_elf and once in the current module. Alternatively
// we could implement a crash key lookup trampoline which defers to
// chrome_elf. We decided to go with the duplicate key registration for
// simplicity.
#if !defined(COMPONENT_BUILD)
crash_keys::RegisterChromeCrashKeys();
crash_keys::RegisterChromeCrashKeys();
#endif
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);
} 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);
}
// Set the client id chrome_elf (in tests this is stubbed).
SetMetricsClientId(client_info ? client_info->client_id.c_str() : nullptr);
}
} // namespace child_process_logging
......@@ -122,7 +122,6 @@ const base::FilePath::CharType kFrameworkExecutableName[] =
#if defined(OS_WIN)
const base::FilePath::CharType kBrowserResourcesDll[] = FPL("chrome.dll");
const base::FilePath::CharType kChromeElfDllName[] = FPL("chrome_elf.dll");
const base::FilePath::CharType kStatusTrayWindowClass[] =
FPL("Chrome_StatusTrayWindow");
#endif // defined(OS_WIN)
......
......@@ -33,7 +33,6 @@ extern const base::FilePath::CharType kFrameworkExecutableName[];
#endif // OS_MACOSX
#if defined(OS_WIN)
extern const base::FilePath::CharType kBrowserResourcesDll[];
extern const base::FilePath::CharType kChromeElfDllName[];
extern const base::FilePath::CharType kStatusTrayWindowClass[];
#endif // defined(OS_WIN)
......
......@@ -28,6 +28,14 @@ windows_manifest("chrome_elf_manifest") {
]
}
# Users of chrome_elf exports can depend on this target, which doesn't
# pin them to linking either chrome_elf.dll or test_stubs.
source_set("chrome_elf_main_include") {
sources = [
"chrome_elf_main.h",
]
}
# We should move chrome_result_codes.h to another target which does not bring
# in the world.
shared_library("chrome_elf") {
......
......@@ -69,3 +69,7 @@ BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
void DumpProcessWithoutCrash() {
elf_crash::DumpWithoutCrashing();
}
void SetMetricsClientId(const char* client_id) {
elf_crash::SetMetricsClientIdImpl(client_id);
}
......@@ -6,7 +6,7 @@
#define CHROME_ELF_CHROME_ELF_MAIN_H_
// These functions are the cross-module import interface to chrome_elf.dll.
// It is used chrome.exe, chrome.dll and other clients of chrome_elf.
// It is used by chrome.exe, chrome.dll and other clients of chrome_elf.
// In tests, these functions are stubbed by implementations in
// chrome_elf_test_stubs.cc.
extern "C" {
......@@ -25,6 +25,9 @@ bool GetUserDataDirectoryThunk(wchar_t* user_data_dir,
void SignalInitializeCrashReporting();
void SignalChromeElf();
// Sets the metrics client ID in crash keys.
void SetMetricsClientId(const char* client_id);
} // extern "C"
#endif // CHROME_ELF_CHROME_ELF_MAIN_H_
......@@ -33,3 +33,5 @@ bool GetUserDataDirectoryThunk(wchar_t* user_data_dir,
return !user_data_dir_path.empty();
}
void SetMetricsClientId(const char* client_id) {}
......@@ -118,29 +118,11 @@ void DumpWithoutCrashing() {
crash_reporter::DumpWithoutCrashing();
}
} // namespace elf_crash
//------------------------------------------------------------------------------
// Exported crash APIs for the rest of the process.
//------------------------------------------------------------------------------
// This helper is invoked by code in chrome.dll to retrieve the crash reports.
// See CrashUploadListCrashpad. Note that we do not pass a std::vector here,
// because we do not want to allocate/free in different modules. The returned
// pointer is read-only.
//
// NOTE: Since the returned pointer references read-only memory that will be
// cleaned up when this DLL unloads, be careful not to reference the memory
// beyond that point (e.g. during tests).
extern "C" {
// This helper is invoked by debugging code in chrome to register the client
// id.
void SetMetricsClientId(const char* client_id) {
void SetMetricsClientIdImpl(const char* client_id) {
if (!g_crash_helper_enabled)
return;
if (client_id)
crash_keys::SetMetricsClientIdFromGUID(client_id);
}
} // extern "C"
} // namespace elf_crash
......@@ -31,6 +31,9 @@ int GenerateCrashDump(EXCEPTION_POINTERS* exception_pointers);
// Generate a crash dump by calling into crashpad.
void DumpWithoutCrashing();
// Set the metrics client ID in crash keys.
void SetMetricsClientIdImpl(const char* client_id);
} // namespace elf_crash
#endif // CHROME_ELF_CRASH_CRASH_HELPER_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment