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

Side by Side Diff: chrome/browser/diagnostics/recon_diagnostics.cc

Issue 7189076: Localize strings, speeds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright dates Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/diagnostics/recon_diagnostics.h" 5 #include "chrome/browser/diagnostics/recon_diagnostics.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "chrome/browser/diagnostics/diagnostics_test.h" 17 #include "chrome/browser/diagnostics/diagnostics_test.h"
18 #include "chrome/browser/platform_util.h" 18 #include "chrome/browser/platform_util.h"
19 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/chrome_version_info.h" 21 #include "chrome/common/chrome_version_info.h"
22 #include "content/common/json_value_serializer.h" 22 #include "content/common/json_value_serializer.h"
23 #include "ui/base/text/bytes_formatting.h"
23 24
24 #if defined(OS_WIN) 25 #if defined(OS_WIN)
25 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
26 #include "chrome/browser/enumerate_modules_model_win.h" 27 #include "chrome/browser/enumerate_modules_model_win.h"
27 #include "chrome/installer/util/install_util.h" 28 #include "chrome/installer/util/install_util.h"
28 #endif 29 #endif
29 30
30 // Reconnaissance diagnostics. These are the first and most critical 31 // Reconnaissance diagnostics. These are the first and most critical
31 // diagnostic tests. Here we check for the existence of critical files. 32 // diagnostic tests. Here we check for the existence of critical files.
32 // TODO(cpu): Define if it makes sense to localize strings. 33 // TODO(cpu): Define if it makes sense to localize strings.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (path_info_.is_directory) { 245 if (path_info_.is_directory) {
245 dir_or_file_size = file_util::ComputeDirectorySize(dir_or_file); 246 dir_or_file_size = file_util::ComputeDirectorySize(dir_or_file);
246 } else { 247 } else {
247 file_util::GetFileSize(dir_or_file, &dir_or_file_size); 248 file_util::GetFileSize(dir_or_file, &dir_or_file_size);
248 } 249 }
249 if (!dir_or_file_size && !path_info_.is_optional) { 250 if (!dir_or_file_size && !path_info_.is_optional) {
250 RecordFailure(ASCIIToUTF16("Cannot obtain size for: ") + 251 RecordFailure(ASCIIToUTF16("Cannot obtain size for: ") +
251 dir_or_file.LossyDisplayName()); 252 dir_or_file.LossyDisplayName());
252 return true; 253 return true;
253 } 254 }
254 DataUnits units = GetByteDisplayUnits(dir_or_file_size); 255 string16 printable_size = ui::FormatBytes(dir_or_file_size);
255 string16 printable_size = FormatBytes(dir_or_file_size, units, true);
256 256
257 if (path_info_.max_size > 0) { 257 if (path_info_.max_size > 0) {
258 if (dir_or_file_size > path_info_.max_size) { 258 if (dir_or_file_size > path_info_.max_size) {
259 RecordFailure(ASCIIToUTF16("Path contents too large (") + 259 RecordFailure(ASCIIToUTF16("Path contents too large (") +
260 printable_size + 260 printable_size +
261 ASCIIToUTF16(") for: ") + 261 ASCIIToUTF16(") for: ") +
262 dir_or_file.LossyDisplayName()); 262 dir_or_file.LossyDisplayName());
263 return true; 263 return true;
264 } 264 }
265 } 265 }
(...skipping 26 matching lines...) Expand all
292 292
293 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { 293 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) {
294 FilePath data_dir; 294 FilePath data_dir;
295 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) 295 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir))
296 return false; 296 return false;
297 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir); 297 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir);
298 if (disk_space < 0) { 298 if (disk_space < 0) {
299 RecordFailure(ASCIIToUTF16("Unable to query free space")); 299 RecordFailure(ASCIIToUTF16("Unable to query free space"));
300 return true; 300 return true;
301 } 301 }
302 DataUnits units = GetByteDisplayUnits(disk_space); 302 string16 printable_size = ui::FormatBytes(disk_space);
303 string16 printable_size = FormatBytes(disk_space, units, true);
304 if (disk_space < 80 * kOneMeg) { 303 if (disk_space < 80 * kOneMeg) {
305 RecordFailure(ASCIIToUTF16("Low disk space : ") + printable_size); 304 RecordFailure(ASCIIToUTF16("Low disk space : ") + printable_size);
306 return true; 305 return true;
307 } 306 }
308 RecordSuccess(ASCIIToUTF16("Free space : ") + printable_size); 307 RecordSuccess(ASCIIToUTF16("Free space : ") + printable_size);
309 return true; 308 return true;
310 } 309 }
311 310
312 private: 311 private:
313 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); 312 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 path = path.Append(chrome::kBookmarksFileName); 415 path = path.Append(chrome::kBookmarksFileName);
417 return new JSONTest(path, ASCIIToUTF16("BookMarks JSON"), 2 * kOneMeg); 416 return new JSONTest(path, ASCIIToUTF16("BookMarks JSON"), 2 * kOneMeg);
418 } 417 }
419 418
420 DiagnosticTest* MakeLocalStateTest() { 419 DiagnosticTest* MakeLocalStateTest() {
421 FilePath path; 420 FilePath path;
422 PathService::Get(chrome::DIR_USER_DATA, &path); 421 PathService::Get(chrome::DIR_USER_DATA, &path);
423 path = path.Append(chrome::kLocalStateFilename); 422 path = path.Append(chrome::kLocalStateFilename);
424 return new JSONTest(path, ASCIIToUTF16("Local State JSON"), 50 * kOneKilo); 423 return new JSONTest(path, ASCIIToUTF16("Local State JSON"), 50 * kOneKilo);
425 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698