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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 "Cannot obtain file size"); | 196 "Cannot obtain file size"); |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 if (file_size > max_file_size_) { | 200 if (file_size > max_file_size_) { |
201 RecordFailure(DIAG_RECON_FILE_TOO_BIG, "File too big"); | 201 RecordFailure(DIAG_RECON_FILE_TOO_BIG, "File too big"); |
202 return true; | 202 return true; |
203 } | 203 } |
204 // Being small enough, we can process it in-memory. | 204 // Being small enough, we can process it in-memory. |
205 std::string json_data; | 205 std::string json_data; |
206 if (!file_util::ReadFileToString(path_, &json_data)) { | 206 if (!base::ReadFileToString(path_, &json_data)) { |
207 RecordFailure(DIAG_RECON_UNABLE_TO_OPEN_FILE, | 207 RecordFailure(DIAG_RECON_UNABLE_TO_OPEN_FILE, |
208 "Could not open file. Possibly locked by another process"); | 208 "Could not open file. Possibly locked by another process"); |
209 return true; | 209 return true; |
210 } | 210 } |
211 | 211 |
212 JSONStringValueSerializer json(json_data); | 212 JSONStringValueSerializer json(json_data); |
213 int error_code = base::JSONReader::JSON_NO_ERROR; | 213 int error_code = base::JSONReader::JSON_NO_ERROR; |
214 std::string error_message; | 214 std::string error_message; |
215 scoped_ptr<Value> json_root(json.Deserialize(&error_code, &error_message)); | 215 scoped_ptr<Value> json_root(json.Deserialize(&error_code, &error_message)); |
216 if (base::JSONReader::JSON_NO_ERROR != error_code) { | 216 if (base::JSONReader::JSON_NO_ERROR != error_code) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 DiagnosticsTest* MakeResourcesFileTest() { | 430 DiagnosticsTest* MakeResourcesFileTest() { |
431 return new PathTest(kPathsToTest[2]); | 431 return new PathTest(kPathsToTest[2]); |
432 } | 432 } |
433 | 433 |
434 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } | 434 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } |
435 | 435 |
436 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } | 436 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } |
437 | 437 |
438 } // namespace diagnostics | 438 } // namespace diagnostics |
OLD | NEW |