OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_version_info.h" | 10 #include "base/file_version_info.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (path_info_.is_directory) { | 196 if (path_info_.is_directory) { |
197 dir_or_file_size = file_util::ComputeDirectorySize(dir_or_file); | 197 dir_or_file_size = file_util::ComputeDirectorySize(dir_or_file); |
198 } else { | 198 } else { |
199 file_util::GetFileSize(dir_or_file, &dir_or_file_size); | 199 file_util::GetFileSize(dir_or_file, &dir_or_file_size); |
200 } | 200 } |
201 if (!dir_or_file_size && !path_info_.is_optional) { | 201 if (!dir_or_file_size && !path_info_.is_optional) { |
202 RecordFailure(ASCIIToUTF16("Cannot obtain size")); | 202 RecordFailure(ASCIIToUTF16("Cannot obtain size")); |
203 return true; | 203 return true; |
204 } | 204 } |
205 DataUnits units = GetByteDisplayUnits(dir_or_file_size); | 205 DataUnits units = GetByteDisplayUnits(dir_or_file_size); |
206 string16 printable_size = | 206 string16 printable_size = FormatBytes(dir_or_file_size, units, true); |
207 WideToUTF16(FormatBytes(dir_or_file_size, units, true)); | |
208 | 207 |
209 if (path_info_.max_size > 0) { | 208 if (path_info_.max_size > 0) { |
210 if (dir_or_file_size > path_info_.max_size) { | 209 if (dir_or_file_size > path_info_.max_size) { |
211 RecordFailure(ASCIIToUTF16("Path is too big: ") + printable_size); | 210 RecordFailure(ASCIIToUTF16("Path is too big: ") + printable_size); |
212 return true; | 211 return true; |
213 } | 212 } |
214 } | 213 } |
215 if (g_install_type->system_level() && !path_info_.test_writable) { | 214 if (g_install_type->system_level() && !path_info_.test_writable) { |
216 RecordSuccess(ASCIIToUTF16("Path exists")); | 215 RecordSuccess(ASCIIToUTF16("Path exists")); |
217 return true; | 216 return true; |
(...skipping 23 matching lines...) Expand all Loading... |
241 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { | 240 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { |
242 FilePath data_dir; | 241 FilePath data_dir; |
243 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) | 242 if (!PathService::Get(chrome::DIR_USER_DATA, &data_dir)) |
244 return false; | 243 return false; |
245 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir); | 244 int64 disk_space = base::SysInfo::AmountOfFreeDiskSpace(data_dir); |
246 if (disk_space < 0) { | 245 if (disk_space < 0) { |
247 RecordFailure(ASCIIToUTF16("Unable to query free space")); | 246 RecordFailure(ASCIIToUTF16("Unable to query free space")); |
248 return true; | 247 return true; |
249 } | 248 } |
250 DataUnits units = GetByteDisplayUnits(disk_space); | 249 DataUnits units = GetByteDisplayUnits(disk_space); |
251 string16 printable_size = | 250 string16 printable_size = FormatBytes(disk_space, units, true); |
252 WideToUTF16(FormatBytes(disk_space, units, true)); | |
253 if (disk_space < 80 * kOneMeg) { | 251 if (disk_space < 80 * kOneMeg) { |
254 RecordFailure(ASCIIToUTF16("Low disk space : ") + printable_size); | 252 RecordFailure(ASCIIToUTF16("Low disk space : ") + printable_size); |
255 return true; | 253 return true; |
256 } | 254 } |
257 RecordSuccess(ASCIIToUTF16("Free space : ") + printable_size); | 255 RecordSuccess(ASCIIToUTF16("Free space : ") + printable_size); |
258 return true; | 256 return true; |
259 } | 257 } |
260 | 258 |
261 private: | 259 private: |
262 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); | 260 DISALLOW_COPY_AND_ASSIGN(DiskSpaceTest); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 path = path.Append(chrome::kBookmarksFileName); | 355 path = path.Append(chrome::kBookmarksFileName); |
358 return new JSONTest(path, ASCIIToUTF16("BookMarks JSON"), 2 * kOneMeg); | 356 return new JSONTest(path, ASCIIToUTF16("BookMarks JSON"), 2 * kOneMeg); |
359 } | 357 } |
360 | 358 |
361 DiagnosticTest* MakeLocalStateTest() { | 359 DiagnosticTest* MakeLocalStateTest() { |
362 FilePath path; | 360 FilePath path; |
363 PathService::Get(chrome::DIR_USER_DATA, &path); | 361 PathService::Get(chrome::DIR_USER_DATA, &path); |
364 path = path.Append(chrome::kLocalStateFilename); | 362 path = path.Append(chrome::kLocalStateFilename); |
365 return new JSONTest(path, ASCIIToUTF16("Local State JSON"), 50 * kOneKilo); | 363 return new JSONTest(path, ASCIIToUTF16("Local State JSON"), 50 * kOneKilo); |
366 } | 364 } |
OLD | NEW |