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

Side by Side Diff: chrome/installer/setup/installer_crash_reporter_client.cc

Issue 1561663003: CL for perf tryjob on win (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/installer/setup/installer_crash_reporter_client.h" 5 #include "chrome/installer/setup/installer_crash_reporter_client.h"
6 6
7 #include "base/debug/crash_logging.h" 7 #include "base/debug/crash_logging.h"
8 #include "base/debug/leak_annotations.h"
8 #include "base/environment.h" 9 #include "base/environment.h"
9 #include "base/file_version_info.h" 10 #include "base/file_version_info.h"
11 #include "base/logging.h"
10 #include "base/path_service.h" 12 #include "base/path_service.h"
11 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
12 #include "base/win/registry.h" 14 #include "base/win/registry.h"
13 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/chrome_version.h" 16 #include "chrome/common/chrome_version.h"
15 #include "chrome/common/env_vars.h" 17 #include "chrome/common/env_vars.h"
16 #include "chrome/installer/setup/installer_crash_reporting.h"
17 #include "chrome/installer/util/google_update_settings.h" 18 #include "chrome/installer/util/google_update_settings.h"
19 #include "chrome/installer/util/installer_crash_reporting.h"
20 #include "chrome/installer/util/installer_state.h"
21 #include "components/crash/content/app/breakpad_win.h"
22 #include "components/crash/content/app/crash_keys_win.h"
18 #include "components/crash/core/common/crash_keys.h" 23 #include "components/crash/core/common/crash_keys.h"
19 24
25 namespace {
26
27 #if defined(COMPONENT_BUILD)
28 // Installed via base::debug::SetCrashKeyReportingFunctions.
29 void SetCrashKeyValue(const base::StringPiece& key,
30 const base::StringPiece& value) {
31 DCHECK(breakpad::CrashKeysWin::keeper());
32 breakpad::CrashKeysWin::keeper()->SetCrashKeyValue(base::UTF8ToUTF16(key),
33 base::UTF8ToUTF16(value));
34 }
35
36 // Installed via base::debug::SetCrashKeyReportingFunctions.
37 void ClearCrashKey(const base::StringPiece& key) {
38 DCHECK(breakpad::CrashKeysWin::keeper());
39 breakpad::CrashKeysWin::keeper()->ClearCrashKeyValue(base::UTF8ToUTF16(key));
40 }
41 #endif // COMPONENT_BUILD
42
43 } // namespace
44
45 void InstallerCrashReporterClient::Configure(
46 const installer::InstallerState& installer_state) {
47 // This is inspired by work done in various parts of Chrome startup to connect
48 // to the crash service. Since the installer does not split its work between
49 // a stub .exe and a main .dll, crash reporting can be configured in one place
50 // right here.
51
52 // Create the crash client and install it (a la MainDllLoader::Launch).
53 InstallerCrashReporterClient *crash_client =
54 new InstallerCrashReporterClient(!installer_state.system_install());
55 ANNOTATE_LEAKING_OBJECT_PTR(crash_client);
56 crash_reporter::SetCrashReporterClient(crash_client);
57
58 breakpad::InitCrashReporter("Chrome Installer");
59
60 // Set up crash keys and the client id (a la child_process_logging::Init()).
61 #if defined(COMPONENT_BUILD)
62 // breakpad::InitCrashReporter takes care of this for static builds but not
63 // component builds due to intricacies of chrome.exe and chrome.dll sharing a
64 // copy of base.dll in that case (for details, see the comment in
65 // components/crash/content/app/breakpad_win.cc).
66 crash_client->RegisterCrashKeys();
67 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey);
68 #endif // COMPONENT_BUILD
69
70 scoped_ptr<metrics::ClientInfo> client_info =
71 GoogleUpdateSettings::LoadMetricsClientInfo();
72 if (client_info)
73 crash_client->SetCrashReporterClientIdFromGUID(client_info->client_id);
74 // TODO(grt): A lack of a client_id at this point generally means that Chrome
75 // has yet to have been launched and picked one. Consider creating it and
76 // setting it here for Chrome to use.
77 }
78
20 InstallerCrashReporterClient::InstallerCrashReporterClient( 79 InstallerCrashReporterClient::InstallerCrashReporterClient(
21 bool is_per_user_install) 80 bool is_per_user_install)
22 : is_per_user_install_(is_per_user_install) { 81 : is_per_user_install_(is_per_user_install) {
23 } 82 }
24 83
25 InstallerCrashReporterClient::~InstallerCrashReporterClient() = default; 84 InstallerCrashReporterClient::~InstallerCrashReporterClient() = default;
26 85
27 void InstallerCrashReporterClient::SetCrashReporterClientIdFromGUID( 86 void InstallerCrashReporterClient::SetCrashReporterClientIdFromGUID(
28 const std::string& client_guid) { 87 const std::string& client_guid) {
29 crash_keys::SetMetricsClientIdFromGUID(client_guid); 88 crash_keys::SetMetricsClientIdFromGUID(client_guid);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 231 }
173 } 232 }
174 233
175 return false; 234 return false;
176 } 235 }
177 236
178 bool InstallerCrashReporterClient::EnableBreakpadForProcess( 237 bool InstallerCrashReporterClient::EnableBreakpadForProcess(
179 const std::string& process_type) { 238 const std::string& process_type) {
180 return true; 239 return true;
181 } 240 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/installer_crash_reporter_client.h ('k') | chrome/installer/setup/installer_crash_reporting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698