| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { | 238 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
| 239 if (!g_install_type) { | 239 if (!g_install_type) { |
| 240 RecordStopFailure(DIAG_RECON_DEPENDENCY, "Install dependency failure"); | 240 RecordStopFailure(DIAG_RECON_DEPENDENCY, "Install dependency failure"); |
| 241 return false; | 241 return false; |
| 242 } | 242 } |
| 243 base::FilePath dir_or_file; | 243 base::FilePath dir_or_file; |
| 244 if (!PathService::Get(path_info_.path_id, &dir_or_file)) { | 244 if (!PathService::Get(path_info_.path_id, &dir_or_file)) { |
| 245 RecordStopFailure(DIAG_RECON_PATH_PROVIDER, "Path provider failure"); | 245 RecordStopFailure(DIAG_RECON_PATH_PROVIDER, "Path provider failure"); |
| 246 return false; | 246 return false; |
| 247 } | 247 } |
| 248 if (!file_util::PathExists(dir_or_file)) { | 248 if (!base::PathExists(dir_or_file)) { |
| 249 RecordFailure( | 249 RecordFailure( |
| 250 DIAG_RECON_PATH_NOT_FOUND, | 250 DIAG_RECON_PATH_NOT_FOUND, |
| 251 "Path not found: " + UTF16ToUTF8(dir_or_file.LossyDisplayName())); | 251 "Path not found: " + UTF16ToUTF8(dir_or_file.LossyDisplayName())); |
| 252 return true; | 252 return true; |
| 253 } | 253 } |
| 254 | 254 |
| 255 int64 dir_or_file_size = 0; | 255 int64 dir_or_file_size = 0; |
| 256 if (path_info_.is_directory) { | 256 if (path_info_.is_directory) { |
| 257 dir_or_file_size = base::ComputeDirectorySize(dir_or_file); | 257 dir_or_file_size = base::ComputeDirectorySize(dir_or_file); |
| 258 } else { | 258 } else { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 // Checks that a given json file can be correctly parsed. | 325 // Checks that a given json file can be correctly parsed. |
| 326 class JSONTest : public DiagnosticsTest { | 326 class JSONTest : public DiagnosticsTest { |
| 327 public: | 327 public: |
| 328 JSONTest(const base::FilePath& path, | 328 JSONTest(const base::FilePath& path, |
| 329 const std::string& id, | 329 const std::string& id, |
| 330 const std::string& name, | 330 const std::string& name, |
| 331 int64 max_file_size) | 331 int64 max_file_size) |
| 332 : DiagnosticsTest(id, name), path_(path), max_file_size_(max_file_size) {} | 332 : DiagnosticsTest(id, name), path_(path), max_file_size_(max_file_size) {} |
| 333 | 333 |
| 334 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { | 334 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) OVERRIDE { |
| 335 if (!file_util::PathExists(path_)) { | 335 if (!base::PathExists(path_)) { |
| 336 RecordFailure(DIAG_RECON_FILE_NOT_FOUND, "File not found"); | 336 RecordFailure(DIAG_RECON_FILE_NOT_FOUND, "File not found"); |
| 337 return true; | 337 return true; |
| 338 } | 338 } |
| 339 int64 file_size; | 339 int64 file_size; |
| 340 if (!file_util::GetFileSize(path_, &file_size)) { | 340 if (!file_util::GetFileSize(path_, &file_size)) { |
| 341 RecordFailure(DIAG_RECON_CANNOT_OBTAIN_FILE_SIZE, | 341 RecordFailure(DIAG_RECON_CANNOT_OBTAIN_FILE_SIZE, |
| 342 "Cannot obtain file size"); | 342 "Cannot obtain file size"); |
| 343 return true; | 343 return true; |
| 344 } | 344 } |
| 345 | 345 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 419 |
| 420 DiagnosticsTest* MakeLocalStateTest() { | 420 DiagnosticsTest* MakeLocalStateTest() { |
| 421 base::FilePath path; | 421 base::FilePath path; |
| 422 PathService::Get(chrome::DIR_USER_DATA, &path); | 422 PathService::Get(chrome::DIR_USER_DATA, &path); |
| 423 path = path.Append(chrome::kLocalStateFilename); | 423 path = path.Append(chrome::kLocalStateFilename); |
| 424 return new JSONTest( | 424 return new JSONTest( |
| 425 path, kJSONLocalStateTest, "Local State JSON", 50 * kOneKilobyte); | 425 path, kJSONLocalStateTest, "Local State JSON", 50 * kOneKilobyte); |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace diagnostics | 428 } // namespace diagnostics |
| OLD | NEW |