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

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

Issue 1899083002: Convert //chrome from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 #include "chrome/app/chrome_crash_reporter_client.h" 5 #include "chrome/app/chrome_crash_reporter_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const std::string& client_guid) { 71 const std::string& client_guid) {
72 crash_keys::SetMetricsClientIdFromGUID(client_guid); 72 crash_keys::SetMetricsClientIdFromGUID(client_guid);
73 } 73 }
74 #endif 74 #endif
75 75
76 #if defined(OS_WIN) 76 #if defined(OS_WIN)
77 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( 77 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation(
78 base::FilePath* crash_dir) { 78 base::FilePath* crash_dir) {
79 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 79 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
80 // location to write breakpad crash dumps can be set. 80 // location to write breakpad crash dumps can be set.
81 scoped_ptr<base::Environment> env(base::Environment::Create()); 81 std::unique_ptr<base::Environment> env(base::Environment::Create());
82 std::string alternate_crash_dump_location; 82 std::string alternate_crash_dump_location;
83 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { 83 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) {
84 *crash_dir = base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); 84 *crash_dir = base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location);
85 return true; 85 return true;
86 } 86 }
87 87
88 return false; 88 return false;
89 } 89 }
90 90
91 void ChromeCrashReporterClient::GetProductNameAndVersion( 91 void ChromeCrashReporterClient::GetProductNameAndVersion(
92 const base::FilePath& exe_path, 92 const base::FilePath& exe_path,
93 base::string16* product_name, 93 base::string16* product_name,
94 base::string16* version, 94 base::string16* version,
95 base::string16* special_build, 95 base::string16* special_build,
96 base::string16* channel_name) { 96 base::string16* channel_name) {
97 DCHECK(product_name); 97 DCHECK(product_name);
98 DCHECK(version); 98 DCHECK(version);
99 DCHECK(special_build); 99 DCHECK(special_build);
100 DCHECK(channel_name); 100 DCHECK(channel_name);
101 101
102 scoped_ptr<FileVersionInfo> version_info( 102 std::unique_ptr<FileVersionInfo> version_info(
103 FileVersionInfo::CreateFileVersionInfo(exe_path)); 103 FileVersionInfo::CreateFileVersionInfo(exe_path));
104 104
105 if (version_info.get()) { 105 if (version_info.get()) {
106 // Get the information from the file. 106 // Get the information from the file.
107 *version = version_info->product_version(); 107 *version = version_info->product_version();
108 if (!version_info->is_official_build()) 108 if (!version_info->is_official_build())
109 version->append(base::ASCIIToUTF16("-devel")); 109 version->append(base::ASCIIToUTF16("-devel"));
110 110
111 *product_name = version_info->product_short_name(); 111 *product_name = version_info->product_short_name();
112 *special_build = version_info->special_build(); 112 *special_build = version_info->special_build();
113 } else { 113 } else {
114 // No version info found. Make up the values. 114 // No version info found. Make up the values.
115 *product_name = base::ASCIIToUTF16("Chrome"); 115 *product_name = base::ASCIIToUTF16("Chrome");
116 *version = base::ASCIIToUTF16("0.0.0.0-devel"); 116 *version = base::ASCIIToUTF16("0.0.0.0-devel");
117 } 117 }
118 118
119 GoogleUpdateSettings::GetChromeChannelAndModifiers( 119 GoogleUpdateSettings::GetChromeChannelAndModifiers(
120 !GetIsPerUserInstall(exe_path), channel_name); 120 !GetIsPerUserInstall(exe_path), channel_name);
121 } 121 }
122 122
123 bool ChromeCrashReporterClient::ShouldShowRestartDialog(base::string16* title, 123 bool ChromeCrashReporterClient::ShouldShowRestartDialog(base::string16* title,
124 base::string16* message, 124 base::string16* message,
125 bool* is_rtl_locale) { 125 bool* is_rtl_locale) {
126 scoped_ptr<base::Environment> env(base::Environment::Create()); 126 std::unique_ptr<base::Environment> env(base::Environment::Create());
127 if (!env->HasVar(env_vars::kShowRestart) || 127 if (!env->HasVar(env_vars::kShowRestart) ||
128 !env->HasVar(env_vars::kRestartInfo) || 128 !env->HasVar(env_vars::kRestartInfo) ||
129 env->HasVar(env_vars::kMetroConnected)) { 129 env->HasVar(env_vars::kMetroConnected)) {
130 return false; 130 return false;
131 } 131 }
132 132
133 std::string restart_info; 133 std::string restart_info;
134 env->GetVar(env_vars::kRestartInfo, &restart_info); 134 env->GetVar(env_vars::kRestartInfo, &restart_info);
135 135
136 // The CHROME_RESTART var contains the dialog strings separated by '|'. 136 // The CHROME_RESTART var contains the dialog strings separated by '|'.
137 // See ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment() 137 // See ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment()
138 // for details. 138 // for details.
139 std::vector<std::string> dlg_strings = base::SplitString( 139 std::vector<std::string> dlg_strings = base::SplitString(
140 restart_info, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 140 restart_info, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
141 141
142 if (dlg_strings.size() < 3) 142 if (dlg_strings.size() < 3)
143 return false; 143 return false;
144 144
145 *title = base::UTF8ToUTF16(dlg_strings[0]); 145 *title = base::UTF8ToUTF16(dlg_strings[0]);
146 *message = base::UTF8ToUTF16(dlg_strings[1]); 146 *message = base::UTF8ToUTF16(dlg_strings[1]);
147 *is_rtl_locale = dlg_strings[2] == env_vars::kRtlLocale; 147 *is_rtl_locale = dlg_strings[2] == env_vars::kRtlLocale;
148 return true; 148 return true;
149 } 149 }
150 150
151 bool ChromeCrashReporterClient::AboutToRestart() { 151 bool ChromeCrashReporterClient::AboutToRestart() {
152 scoped_ptr<base::Environment> env(base::Environment::Create()); 152 std::unique_ptr<base::Environment> env(base::Environment::Create());
153 if (!env->HasVar(env_vars::kRestartInfo)) 153 if (!env->HasVar(env_vars::kRestartInfo))
154 return false; 154 return false;
155 155
156 env->SetVar(env_vars::kShowRestart, "1"); 156 env->SetVar(env_vars::kShowRestart, "1");
157 return true; 157 return true;
158 } 158 }
159 159
160 bool ChromeCrashReporterClient::GetDeferredUploadsSupported( 160 bool ChromeCrashReporterClient::GetDeferredUploadsSupported(
161 bool is_per_user_install) { 161 bool is_per_user_install) {
162 Version update_version = GoogleUpdateSettings::GetGoogleUpdateVersion( 162 Version update_version = GoogleUpdateSettings::GetGoogleUpdateVersion(
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() { 276 base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() {
277 return base::FilePath(CrashUploadList::kReporterLogFilename); 277 return base::FilePath(CrashUploadList::kReporterLogFilename);
278 } 278 }
279 #endif 279 #endif
280 280
281 bool ChromeCrashReporterClient::GetCrashDumpLocation( 281 bool ChromeCrashReporterClient::GetCrashDumpLocation(
282 base::FilePath* crash_dir) { 282 base::FilePath* crash_dir) {
283 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate 283 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
284 // location to write breakpad crash dumps can be set. 284 // location to write breakpad crash dumps can be set.
285 scoped_ptr<base::Environment> env(base::Environment::Create()); 285 std::unique_ptr<base::Environment> env(base::Environment::Create());
286 std::string alternate_crash_dump_location; 286 std::string alternate_crash_dump_location;
287 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { 287 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) {
288 base::FilePath crash_dumps_dir_path = 288 base::FilePath crash_dumps_dir_path =
289 base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); 289 base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location);
290 290
291 #if defined(OS_WIN) 291 #if defined(OS_WIN)
292 // If this environment variable exists, then for the time being, 292 // If this environment variable exists, then for the time being,
293 // short-circuit how it's handled on Windows. Honoring this 293 // short-circuit how it's handled on Windows. Honoring this
294 // variable is required in order to symbolize stack traces in 294 // variable is required in order to symbolize stack traces in
295 // Telemetry based tests: http://crbug.com/561763. 295 // Telemetry based tests: http://crbug.com/561763.
(...skipping 11 matching lines...) Expand all
307 #else 307 #else
308 return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); 308 return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir);
309 #endif 309 #endif
310 } 310 }
311 311
312 size_t ChromeCrashReporterClient::RegisterCrashKeys() { 312 size_t ChromeCrashReporterClient::RegisterCrashKeys() {
313 return crash_keys::RegisterChromeCrashKeys(); 313 return crash_keys::RegisterChromeCrashKeys();
314 } 314 }
315 315
316 bool ChromeCrashReporterClient::IsRunningUnattended() { 316 bool ChromeCrashReporterClient::IsRunningUnattended() {
317 scoped_ptr<base::Environment> env(base::Environment::Create()); 317 std::unique_ptr<base::Environment> env(base::Environment::Create());
318 return env->HasVar(env_vars::kHeadless); 318 return env->HasVar(env_vars::kHeadless);
319 } 319 }
320 320
321 bool ChromeCrashReporterClient::GetCollectStatsConsent() { 321 bool ChromeCrashReporterClient::GetCollectStatsConsent() {
322 #if defined(GOOGLE_CHROME_BUILD) 322 #if defined(GOOGLE_CHROME_BUILD)
323 bool is_official_chrome_build = true; 323 bool is_official_chrome_build = true;
324 #else 324 #else
325 bool is_official_chrome_build = false; 325 bool is_official_chrome_build = false;
326 #endif 326 #endif
327 327
(...skipping 24 matching lines...) Expand all
352 } 352 }
353 #endif 353 #endif
354 354
355 bool ChromeCrashReporterClient::EnableBreakpadForProcess( 355 bool ChromeCrashReporterClient::EnableBreakpadForProcess(
356 const std::string& process_type) { 356 const std::string& process_type) {
357 return process_type == switches::kRendererProcess || 357 return process_type == switches::kRendererProcess ||
358 process_type == switches::kPpapiPluginProcess || 358 process_type == switches::kPpapiPluginProcess ||
359 process_type == switches::kZygoteProcess || 359 process_type == switches::kZygoteProcess ||
360 process_type == switches::kGpuProcess; 360 process_type == switches::kGpuProcess;
361 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698