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

Side by Side Diff: chrome/app/chrome_crash_reporter_client_win.cc

Issue 2031833002: Remove FilePath usage from the CrashReporterClient interface on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // TODO(ananta/scottmg) 5 // TODO(ananta/scottmg)
6 // Add test coverage for Crashpad. 6 // Add test coverage for Crashpad.
7 #include "chrome/app/chrome_crash_reporter_client_win.h" 7 #include "chrome/app/chrome_crash_reporter_client_win.h"
8 8
9 #include <assert.h>
9 #include <windows.h> 10 #include <windows.h>
10 11
11 #include <memory> 12 #include <memory>
12 #include <string> 13 #include <string>
13 14
14 #include "base/command_line.h"
15 #include "base/files/file_path.h"
16 #include "base/logging.h"
17 #include "base/path_service.h"
18 #include "base/strings/string_split.h"
19 #include "base/strings/utf_string_conversions.h"
20 #include "base/version.h"
21 #include "build/build_config.h" 15 #include "build/build_config.h"
22 #include "chrome/common/chrome_result_codes.h" 16 #include "chrome/common/chrome_result_codes.h"
23 #include "chrome/common/crash_keys.h" 17 #include "chrome/common/crash_keys.h"
24 #include "chrome/common/env_vars.h"
25 #include "chrome/install_static/install_util.h" 18 #include "chrome/install_static/install_util.h"
26 #include "content/public/common/content_switches.h"
27 19
28 namespace { 20 namespace {
29 21
30 // This is the minimum version of google update that is required for deferred 22 // This is the minimum version of google update that is required for deferred
31 // crash uploads to work. 23 // crash uploads to work.
32 const char kMinUpdateVersion[] = "1.3.21.115"; 24 const char kMinUpdateVersion[] = "1.3.21.115";
33 25
34 } // namespace 26 } // namespace
35 27
36 ChromeCrashReporterClient::ChromeCrashReporterClient() {} 28 ChromeCrashReporterClient::ChromeCrashReporterClient() {}
37 29
38 ChromeCrashReporterClient::~ChromeCrashReporterClient() {} 30 ChromeCrashReporterClient::~ChromeCrashReporterClient() {}
39 31
40 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( 32 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation(
41 base::FilePath* crash_dir) { 33 base::string16* crash_dir) {
42 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 34 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
43 // location to write breakpad crash dumps can be set. 35 // location to write breakpad crash dumps can be set.
44 std::string alternate_crash_dump_location = 36 std::string alternate_crash_dump_location =
45 install_static::GetEnvironmentString("BREAKPAD_DUMP_LOCATION"); 37 install_static::GetEnvironmentString("BREAKPAD_DUMP_LOCATION");
46 if (!alternate_crash_dump_location.empty()) { 38 if (!alternate_crash_dump_location.empty()) {
47 *crash_dir = base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); 39 *crash_dir = install_static::UTF8ToUTF16(alternate_crash_dump_location);
grt (UTC plus 2) 2016/06/02 12:55:33 GetEnvironmentString does a UTF16ToUTF8 under the
ananta 2016/06/02 20:34:20 Done. Added GetEnvironmentString16, SetEnvironment
48 return true; 40 return true;
49 } 41 }
50 return false; 42 return false;
51 } 43 }
52 44
53 void ChromeCrashReporterClient::GetProductNameAndVersion( 45 void ChromeCrashReporterClient::GetProductNameAndVersion(
54 const base::FilePath& exe_path, 46 const base::string16& exe_path,
55 base::string16* product_name, 47 base::string16* product_name,
56 base::string16* version, 48 base::string16* version,
57 base::string16* special_build, 49 base::string16* special_build,
58 base::string16* channel_name) { 50 base::string16* channel_name) {
59 DCHECK(product_name); 51 assert(product_name);
60 DCHECK(version); 52 assert(version);
61 DCHECK(special_build); 53 assert(special_build);
62 DCHECK(channel_name); 54 assert(channel_name);
63 55
64 install_static::GetExecutableVersionDetails( 56 install_static::GetExecutableVersionDetails(
65 exe_path.value(), product_name, version, special_build, channel_name); 57 exe_path, product_name, version, special_build, channel_name);
66 } 58 }
67 59
68 bool ChromeCrashReporterClient::ShouldShowRestartDialog(base::string16* title, 60 bool ChromeCrashReporterClient::ShouldShowRestartDialog(base::string16* title,
69 base::string16* message, 61 base::string16* message,
70 bool* is_rtl_locale) { 62 bool* is_rtl_locale) {
71 if (!install_static::HasEnvironmentVariable(env_vars::kShowRestart) || 63 if (!install_static::HasEnvironmentVariable(install_static::kShowRestart) ||
72 !install_static::HasEnvironmentVariable(env_vars::kRestartInfo) || 64 !install_static::HasEnvironmentVariable(install_static::kRestartInfo)) {
73 install_static::HasEnvironmentVariable(env_vars::kMetroConnected)) {
74 return false; 65 return false;
75 } 66 }
76 67
77 std::string restart_info = 68 std::string restart_info =
78 install_static::GetEnvironmentString(env_vars::kRestartInfo); 69 install_static::GetEnvironmentString(install_static::kRestartInfo);
grt (UTC plus 2) 2016/06/02 12:55:33 another spot where a string16 GetEnvironmentString
ananta 2016/06/02 20:34:20 Done.
79 70
80 // The CHROME_RESTART var contains the dialog strings separated by '|'. 71 // The CHROME_RESTART var contains the dialog strings separated by '|'.
81 // See ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment() 72 // See ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment()
82 // for details. 73 // for details.
83 std::vector<std::string> dlg_strings = base::SplitString( 74 std::vector<std::string> dlg_strings = install_static::TokenizeString(
84 restart_info, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 75 restart_info, '|', true); // true = Trim shitespace.
85 76
86 if (dlg_strings.size() < 3) 77 if (dlg_strings.size() < 3)
87 return false; 78 return false;
88 79
89 *title = base::UTF8ToUTF16(dlg_strings[0]); 80 *title = install_static::UTF8ToUTF16(dlg_strings[0]);
90 *message = base::UTF8ToUTF16(dlg_strings[1]); 81 *message = install_static::UTF8ToUTF16(dlg_strings[1]);
91 *is_rtl_locale = dlg_strings[2] == env_vars::kRtlLocale; 82 *is_rtl_locale = dlg_strings[2] == install_static::kRtlLocale;
92 return true; 83 return true;
93 } 84 }
94 85
95 bool ChromeCrashReporterClient::AboutToRestart() { 86 bool ChromeCrashReporterClient::AboutToRestart() {
96 if (!install_static::HasEnvironmentVariable(env_vars::kRestartInfo)) 87 if (!install_static::HasEnvironmentVariable(install_static::kRestartInfo))
97 return false; 88 return false;
98 89
99 install_static::SetEnvironmentString(env_vars::kShowRestart, "1"); 90 install_static::SetEnvironmentString(install_static::kShowRestart, "1");
100 return true; 91 return true;
101 } 92 }
102 93
103 bool ChromeCrashReporterClient::GetDeferredUploadsSupported( 94 bool ChromeCrashReporterClient::GetDeferredUploadsSupported(
grt (UTC plus 2) 2016/06/02 12:55:33 i was under the impression that this feature never
ananta 2016/06/02 20:34:20 Done.
grt (UTC plus 2) 2016/06/02 22:57:44 Thanks. scottmg: could you confirm that my read is
scottmg 2016/06/02 23:01:09 Yeah, I agree. I have no idea what that is, and it
104 bool is_per_user_install) { 95 bool is_per_user_install) {
105 Version update_version(install_static::GetGoogleUpdateVersion()); 96 std::string update_version = install_static::GetGoogleUpdateVersion();
106 return update_version.IsValid() && 97 if (update_version.empty())
107 update_version >= base::Version(kMinUpdateVersion); 98 return false;
99 int result = 0;
100 install_static::CompareVersionStrings(update_version,
101 kMinUpdateVersion, &result);
102 return result >= 0;
108 } 103 }
109 104
110 bool ChromeCrashReporterClient::GetIsPerUserInstall( 105 bool ChromeCrashReporterClient::GetIsPerUserInstall(
111 const base::FilePath& exe_path) { 106 const base::string16& exe_path) {
112 return !install_static::IsSystemInstall(exe_path.value().c_str()); 107 return !install_static::IsSystemInstall(exe_path.c_str());
113 } 108 }
114 109
115 bool ChromeCrashReporterClient::GetShouldDumpLargerDumps( 110 bool ChromeCrashReporterClient::GetShouldDumpLargerDumps(
116 bool is_per_user_install) { 111 bool is_per_user_install) {
117 base::string16 channel_name; 112 base::string16 channel_name;
118 install_static::GetChromeChannelName(is_per_user_install, 113 install_static::GetChromeChannelName(is_per_user_install,
119 false, // !add_modifier 114 false, // !add_modifier
120 &channel_name); 115 &channel_name);
121 // Capture more detail in crash dumps for Beta, Dev, Canary channels and 116 // Capture more detail in crash dumps for Beta, Dev, Canary channels and
122 // if channel is unknown (e.g. Chromium or developer builds). 117 // if channel is unknown (e.g. Chromium or developer builds).
(...skipping 13 matching lines...) Expand all
136 // reporter. 131 // reporter.
137 // Since the configuration management infrastructure is not initialized at 132 // Since the configuration management infrastructure is not initialized at
138 // this point, we read the corresponding registry key directly. The return 133 // this point, we read the corresponding registry key directly. The return
139 // status indicates whether policy data was successfully read. If it is true, 134 // status indicates whether policy data was successfully read. If it is true,
140 // |breakpad_enabled| contains the value set by policy. 135 // |breakpad_enabled| contains the value set by policy.
141 return install_static::ReportingIsEnforcedByPolicy(crashpad_enabled); 136 return install_static::ReportingIsEnforcedByPolicy(crashpad_enabled);
142 } 137 }
143 138
144 139
145 bool ChromeCrashReporterClient::GetCrashDumpLocation( 140 bool ChromeCrashReporterClient::GetCrashDumpLocation(
146 base::FilePath* crash_dir) { 141 base::string16* crash_dir) {
147 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 142 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
148 // location to write breakpad crash dumps can be set. 143 // location to write breakpad crash dumps can be set.
149 // If this environment variable exists, then for the time being, 144 // If this environment variable exists, then for the time being,
150 // short-circuit how it's handled on Windows. Honoring this 145 // short-circuit how it's handled on Windows. Honoring this
151 // variable is required in order to symbolize stack traces in 146 // variable is required in order to symbolize stack traces in
152 // Telemetry based tests: http://crbug.com/561763. 147 // Telemetry based tests: http://crbug.com/561763.
153 if (GetAlternativeCrashDumpLocation(crash_dir)) 148 if (GetAlternativeCrashDumpLocation(crash_dir))
154 return true; 149 return true;
155 150
156 // TODO(scottmg): Consider supporting --user-data-dir. See 151 // TODO(scottmg): Consider supporting --user-data-dir. See
157 // https://crbug.com/565446. 152 // https://crbug.com/565446.
158 base::string16 crash_dump_location; 153 return install_static::GetDefaultCrashDumpLocation(crash_dir);
159 if (!install_static::GetDefaultCrashDumpLocation(&crash_dump_location))
160 return false;
161 *crash_dir = base::FilePath(crash_dump_location);
162 return true;
163 } 154 }
164 155
165 size_t ChromeCrashReporterClient::RegisterCrashKeys() { 156 size_t ChromeCrashReporterClient::RegisterCrashKeys() {
166 return crash_keys::RegisterChromeCrashKeys(); 157 return crash_keys::RegisterChromeCrashKeys();
167 } 158 }
168 159
169 bool ChromeCrashReporterClient::IsRunningUnattended() { 160 bool ChromeCrashReporterClient::IsRunningUnattended() {
170 return install_static::HasEnvironmentVariable(env_vars::kHeadless); 161 return install_static::HasEnvironmentVariable(install_static::kHeadless);
171 } 162 }
172 163
173 bool ChromeCrashReporterClient::GetCollectStatsConsent() { 164 bool ChromeCrashReporterClient::GetCollectStatsConsent() {
174 return install_static::GetCollectStatsConsent(); 165 return install_static::GetCollectStatsConsent();
175 } 166 }
176 167
177 bool ChromeCrashReporterClient::EnableBreakpadForProcess( 168 bool ChromeCrashReporterClient::EnableBreakpadForProcess(
178 const std::string& process_type) { 169 const std::string& process_type) {
179 return process_type == switches::kRendererProcess || 170 return process_type == install_static::kRendererProcess ||
180 process_type == switches::kPpapiPluginProcess || 171 process_type == install_static::kPpapiPluginProcess ||
181 process_type == switches::kZygoteProcess || 172 process_type == install_static::kZygoteProcess ||
182 process_type == switches::kGpuProcess; 173 process_type == install_static::kGpuProcess;
183 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698