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

Side by Side Diff: chrome/common/child_process_logging_win.cc

Issue 2114533002: Switch chrome_elf exception handling from breakpad to crashpad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add dependencies on the chrome_elf_common target in the blacklist target. Previously this came in i… Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | chrome/common/chrome_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/child_process_logging.h" 5 #include "chrome/common/child_process_logging.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 11 matching lines...) Expand all
22 // exported in breakpad_win.cc/crashpad_win.cc: 22 // exported in breakpad_win.cc/crashpad_win.cc:
23 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl. 23 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl.
24 typedef void(__cdecl* SetCrashKeyValue)(const wchar_t*, const wchar_t*); 24 typedef void(__cdecl* SetCrashKeyValue)(const wchar_t*, const wchar_t*);
25 25
26 // exported in breakpad_win.cc/crashpad_win.cc: 26 // exported in breakpad_win.cc/crashpad_win.cc:
27 // void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl. 27 // void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl.
28 typedef void(__cdecl* ClearCrashKeyValue)(const wchar_t*); 28 typedef void(__cdecl* ClearCrashKeyValue)(const wchar_t*);
29 29
30 void SetCrashKeyValueTrampoline(const base::StringPiece& key, 30 void SetCrashKeyValueTrampoline(const base::StringPiece& key,
31 const base::StringPiece& value) { 31 const base::StringPiece& value) {
32 static SetCrashKeyValue set_crash_key = [](){ 32 static SetCrashKeyValue set_crash_key = []() {
33 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); 33 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
34 return reinterpret_cast<SetCrashKeyValue>( 34 return reinterpret_cast<SetCrashKeyValue>(
35 exe_module ? GetProcAddress(exe_module, "SetCrashKeyValueImpl") 35 elf_module ? GetProcAddress(elf_module, "SetCrashKeyValueImpl")
36 : nullptr); 36 : nullptr);
37 }(); 37 }();
38 if (set_crash_key) { 38 if (set_crash_key) {
39 (set_crash_key)(base::UTF8ToWide(key).data(), 39 (set_crash_key)(base::UTF8ToWide(key).data(),
40 base::UTF8ToWide(value).data()); 40 base::UTF8ToWide(value).data());
41 } 41 }
42 } 42 }
43 43
44 void ClearCrashKeyValueTrampoline(const base::StringPiece& key) { 44 void ClearCrashKeyValueTrampoline(const base::StringPiece& key) {
45 static ClearCrashKeyValue clear_crash_key = [](){ 45 static ClearCrashKeyValue clear_crash_key = []() {
46 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); 46 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
47 return reinterpret_cast<ClearCrashKeyValue>( 47 return reinterpret_cast<ClearCrashKeyValue>(
48 exe_module ? GetProcAddress(exe_module, "ClearCrashKeyValueImpl") 48 elf_module ? GetProcAddress(elf_module, "ClearCrashKeyValueImpl")
49 : nullptr); 49 : nullptr);
50 }(); 50 }();
51 if (clear_crash_key) 51 if (clear_crash_key)
52 (clear_crash_key)(base::UTF8ToWide(key).data()); 52 (clear_crash_key)(base::UTF8ToWide(key).data());
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 void Init() { 57 void Init() {
58 crash_keys::RegisterChromeCrashKeys();
59 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline, 58 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline,
60 &ClearCrashKeyValueTrampoline); 59 &ClearCrashKeyValueTrampoline);
61 60
62 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but 61 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but
63 // because of the aforementioned issue, crash keys aren't ready yet at the 62 // because of the aforementioned issue, crash keys aren't ready yet at the
64 // time of Breakpad initialization, load the client id backed up in Google 63 // time of Breakpad initialization, load the client id backed up in Google
65 // Update settings instead. 64 // Update settings instead.
65 // Please note if we are using Crashpad via chrome_elf then we need to call
66 // into chrome_elf to pass in the client id.
66 std::unique_ptr<metrics::ClientInfo> client_info = 67 std::unique_ptr<metrics::ClientInfo> client_info =
67 GoogleUpdateSettings::LoadMetricsClientInfo(); 68 GoogleUpdateSettings::LoadMetricsClientInfo();
68 if (client_info) 69
69 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); 70 // Set the client id in chrome_elf if it is loaded. We should not be
71 // registering crash keys in this case as that would already have been
72 // done by chrome_elf.
73 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
74 if (elf_module) {
75 // TODO(ananta)
76 // Remove this when the change to not require crash key registration lands.
77 // Please note that we are registering the crash keys twice if chrome_elf is
78 // loaded. Once in chrome_elf and once in the current module. Alternatively
79 // we could implement a crash key lookup trampoline which defers to
80 // chrome_elf. We decided to go with the duplicate key registration for
81 // simplicity.
82 #if !defined(COMPONENT_BUILD)
83 crash_keys::RegisterChromeCrashKeys();
84 #endif
85 using SetMetricsClientIdFunction = void (*)(const char* client_id);
86 SetMetricsClientIdFunction set_metrics_id_fn =
87 reinterpret_cast<SetMetricsClientIdFunction>(
88 ::GetProcAddress(elf_module, "SetMetricsClientId"));
89 DCHECK(set_metrics_id_fn);
90 set_metrics_id_fn(client_info ? client_info->client_id.c_str() : nullptr);
91 } else {
92 // TODO(ananta)
93 // Remove this when the change to not require crash key registration lands.
94 crash_keys::RegisterChromeCrashKeys();
95 if (client_info)
96 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id);
97 }
70 } 98 }
71 99
72 } // namespace child_process_logging 100 } // namespace child_process_logging
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | chrome/common/chrome_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698