1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/common/child_process_logging.h"
9 #include "base/debug/crash_logging.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/common/chrome_constants.h"
12 #include "chrome/common/crash_keys.h"
14 namespace child_process_logging
{
18 // exported in breakpad_win.cc:
19 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl.
20 typedef void (__cdecl
*SetCrashKeyValue
)(const wchar_t*, const wchar_t*);
22 // exported in breakpad_win.cc:
23 // void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl.
24 typedef void (__cdecl
*ClearCrashKeyValue
)(const wchar_t*);
26 void SetCrashKeyValueTrampoline(const base::StringPiece
& key
,
27 const base::StringPiece
& value
) {
28 static SetCrashKeyValue set_crash_key
= NULL
;
30 HMODULE exe_module
= GetModuleHandle(chrome::kBrowserProcessExecutableName
);
33 set_crash_key
= reinterpret_cast<SetCrashKeyValue
>(
34 GetProcAddress(exe_module
, "SetCrashKeyValueImpl"));
38 (set_crash_key
)(base::UTF8ToWide(key
).data(),
39 base::UTF8ToWide(value
).data());
43 void ClearCrashKeyValueTrampoline(const base::StringPiece
& key
) {
44 static ClearCrashKeyValue clear_crash_key
= NULL
;
45 if (!clear_crash_key
) {
46 HMODULE exe_module
= GetModuleHandle(chrome::kBrowserProcessExecutableName
);
49 clear_crash_key
= reinterpret_cast<ClearCrashKeyValue
>(
50 GetProcAddress(exe_module
, "ClearCrashKeyValueImpl"));
54 (clear_crash_key
)(base::UTF8ToWide(key
).data());
60 // Note: on other platforms, this is set up during Breakpad initialization,
61 // in ChromeBreakpadClient. But on Windows, that is before the DLL module is
62 // loaded, which is a prerequisite of the crash key system.
63 crash_keys::RegisterChromeCrashKeys();
64 base::debug::SetCrashKeyReportingFunctions(
65 &SetCrashKeyValueTrampoline
, &ClearCrashKeyValueTrampoline
);
68 } // namespace child_process_logging