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

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

Issue 2377963002: restore LOG_FATAL crash key on windows
Patch Set: move CrashMessageHandler out of base Created 4 years, 1 month 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/app/chrome_crash_reporter_client_win.cc ('k') | chrome/common/crash_keys.cc » ('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
11 #include "base/auto_reset.h"
11 #include "base/debug/crash_logging.h" 12 #include "base/debug/crash_logging.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/common/chrome_constants.h" 14 #include "chrome/common/chrome_constants.h"
14 #include "chrome/common/crash_keys.h" 15 #include "chrome/common/crash_keys.h"
15 #include "chrome/installer/util/google_update_settings.h" 16 #include "chrome/installer/util/google_update_settings.h"
16 #include "components/metrics/client_info.h" 17 #include "components/metrics/client_info.h"
17 18
18 namespace child_process_logging { 19 namespace child_process_logging {
19 20
20 namespace { 21 namespace {
(...skipping 24 matching lines...) Expand all
45 static ClearCrashKeyValue clear_crash_key = []() { 46 static ClearCrashKeyValue clear_crash_key = []() {
46 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); 47 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
47 return reinterpret_cast<ClearCrashKeyValue>( 48 return reinterpret_cast<ClearCrashKeyValue>(
48 elf_module ? GetProcAddress(elf_module, "ClearCrashKeyValueImpl") 49 elf_module ? GetProcAddress(elf_module, "ClearCrashKeyValueImpl")
49 : nullptr); 50 : nullptr);
50 }(); 51 }();
51 if (clear_crash_key) 52 if (clear_crash_key)
52 (clear_crash_key)(base::UTF8ToWide(key).data()); 53 (clear_crash_key)(base::UTF8ToWide(key).data());
53 } 54 }
54 55
56 // Please keep synced with one in crashpad.cc.
57 void CrashMessageHandler(const std::string& message) {
58 // In case of an out-of-memory condition, this code could be reentered when
59 // constructing and storing the key. Using a static is not thread-safe, but
60 // if multiple threads are in the process of a fatal crash at the same time,
61 // this should work.
62 static bool guarded = false;
63 if (!guarded) {
64 base::AutoReset<bool> guard(&guarded, true);
65 base::debug::SetCrashKeyValue("LOG_FATAL", message);
66 }
67 }
68
55 } // namespace 69 } // namespace
56 70
57 void Init() { 71 void Init() {
58 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline, 72 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline,
59 &ClearCrashKeyValueTrampoline); 73 &ClearCrashKeyValueTrampoline);
74 logging::SetCrashMessageHandler(CrashMessageHandler);
60 75
61 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but 76 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but
62 // because of the aforementioned issue, crash keys aren't ready yet at the 77 // because of the aforementioned issue, crash keys aren't ready yet at the
63 // time of Breakpad initialization, load the client id backed up in Google 78 // time of Breakpad initialization, load the client id backed up in Google
64 // Update settings instead. 79 // Update settings instead.
65 // Please note if we are using Crashpad via chrome_elf then we need to call 80 // 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. 81 // into chrome_elf to pass in the client id.
67 std::unique_ptr<metrics::ClientInfo> client_info = 82 std::unique_ptr<metrics::ClientInfo> client_info =
68 GoogleUpdateSettings::LoadMetricsClientInfo(); 83 GoogleUpdateSettings::LoadMetricsClientInfo();
69 84
(...skipping 21 matching lines...) Expand all
91 } else { 106 } else {
92 // TODO(ananta) 107 // TODO(ananta)
93 // Remove this when the change to not require crash key registration lands. 108 // Remove this when the change to not require crash key registration lands.
94 crash_keys::RegisterChromeCrashKeys(); 109 crash_keys::RegisterChromeCrashKeys();
95 if (client_info) 110 if (client_info)
96 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); 111 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id);
97 } 112 }
98 } 113 }
99 114
100 } // namespace child_process_logging 115 } // namespace child_process_logging
OLDNEW
« no previous file with comments | « chrome/app/chrome_crash_reporter_client_win.cc ('k') | chrome/common/crash_keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698