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

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

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 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 (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/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return true; 203 return true;
204 } 204 }
205 // Being small enough, we can process it in-memory. 205 // Being small enough, we can process it in-memory.
206 std::string json_data; 206 std::string json_data;
207 if (!base::ReadFileToString(path_, &json_data)) { 207 if (!base::ReadFileToString(path_, &json_data)) {
208 RecordFailure(DIAG_RECON_UNABLE_TO_OPEN_FILE, 208 RecordFailure(DIAG_RECON_UNABLE_TO_OPEN_FILE,
209 "Could not open file. Possibly locked by another process"); 209 "Could not open file. Possibly locked by another process");
210 return true; 210 return true;
211 } 211 }
212 212
213 JSONStringValueSerializer json(json_data); 213 JSONStringValueDeserializer json(json_data);
214 int error_code = base::JSONReader::JSON_NO_ERROR; 214 int error_code = base::JSONReader::JSON_NO_ERROR;
215 std::string error_message; 215 std::string error_message;
216 scoped_ptr<base::Value> json_root( 216 scoped_ptr<base::Value> json_root(
217 json.Deserialize(&error_code, &error_message)); 217 json.Deserialize(&error_code, &error_message));
218 if (base::JSONReader::JSON_NO_ERROR != error_code) { 218 if (base::JSONReader::JSON_NO_ERROR != error_code) {
219 if (error_message.empty()) { 219 if (error_message.empty()) {
220 error_message = "Parse error " + base::IntToString(error_code); 220 error_message = "Parse error " + base::IntToString(error_code);
221 } 221 }
222 RecordFailure(DIAG_RECON_PARSE_ERROR, error_message); 222 RecordFailure(DIAG_RECON_PARSE_ERROR, error_message);
223 return true; 223 return true;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 428
429 DiagnosticsTest* MakeResourcesFileTest() { 429 DiagnosticsTest* MakeResourcesFileTest() {
430 return new PathTest(kPathsToTest[2]); 430 return new PathTest(kPathsToTest[2]);
431 } 431 }
432 432
433 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } 433 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); }
434 434
435 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } 435 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); }
436 436
437 } // namespace diagnostics 437 } // namespace diagnostics
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/test/component_installers_unittest.cc ('k') | chrome/browser/drive/fake_drive_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698