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

Side by Side 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: Remove the key registration code from chrome_elf for the code path taken by the child process loggi… 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
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,
60 &ClearCrashKeyValueTrampoline);
61
62 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but 58 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but
63 // because of the aforementioned issue, crash keys aren't ready yet at the 59 // 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 60 // time of Breakpad initialization, load the client id backed up in Google
65 // Update settings instead. 61 // Update settings instead.
62 // Please note if we are using Crashpad via chrome_elf then we need to call
63 // into chrome_elf to pass in the client id.
66 std::unique_ptr<metrics::ClientInfo> client_info = 64 std::unique_ptr<metrics::ClientInfo> client_info =
67 GoogleUpdateSettings::LoadMetricsClientInfo(); 65 GoogleUpdateSettings::LoadMetricsClientInfo();
68 if (client_info) 66
69 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); 67 // Set the client id in chrome_elf if it is loaded. We should not be
68 // registering crash keys in this case as that would already have been
69 // done by chrome_elf.
70 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
71 if (elf_module) {
72 using SetMetricsClientIdFunction = void (*)(const char* client_id);
73 SetMetricsClientIdFunction set_metrics_id_fn =
74 reinterpret_cast<SetMetricsClientIdFunction>(
75 ::GetProcAddress(elf_module, "SetMetricsClientId"));
76 DCHECK(set_metrics_id_fn);
77 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
78 } else {
79 // TODO(ananta)
80 // Remove this when the change to not require crash key registration lands.
81 crash_keys::RegisterChromeCrashKeys();
82 if (client_info)
83 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id);
84 }
85
86 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline,
87 &ClearCrashKeyValueTrampoline);
70 } 88 }
71 89
72 } // namespace child_process_logging 90 } // namespace child_process_logging
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698