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

Side by Side Diff: base/json/json_file_value_serializer.cc

Issue 1394993004: Make ValueDeserializer::Deserialize return scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and add todo about not failed trybot Created 5 years, 2 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
« no previous file with comments | « base/json/json_file_value_serializer.h ('k') | base/json/json_string_value_serializer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/json/json_file_value_serializer.h" 5 #include "base/json/json_file_value_serializer.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 case JSON_FILE_LOCKED: 93 case JSON_FILE_LOCKED:
94 return kFileLocked; 94 return kFileLocked;
95 case JSON_NO_SUCH_FILE: 95 case JSON_NO_SUCH_FILE:
96 return kNoSuchFile; 96 return kNoSuchFile;
97 default: 97 default:
98 NOTREACHED(); 98 NOTREACHED();
99 return ""; 99 return "";
100 } 100 }
101 } 101 }
102 102
103 base::Value* JSONFileValueDeserializer::Deserialize(int* error_code, 103 scoped_ptr<base::Value> JSONFileValueDeserializer::Deserialize(
104 std::string* error_str) { 104 int* error_code,
105 std::string* error_str) {
105 std::string json_string; 106 std::string json_string;
106 int error = ReadFileToString(&json_string); 107 int error = ReadFileToString(&json_string);
107 if (error != JSON_NO_ERROR) { 108 if (error != JSON_NO_ERROR) {
108 if (error_code) 109 if (error_code)
109 *error_code = error; 110 *error_code = error;
110 if (error_str) 111 if (error_str)
111 *error_str = GetErrorMessageForCode(error); 112 *error_str = GetErrorMessageForCode(error);
112 return NULL; 113 return NULL;
113 } 114 }
114 115
115 JSONStringValueDeserializer deserializer(json_string); 116 JSONStringValueDeserializer deserializer(json_string);
116 deserializer.set_allow_trailing_comma(allow_trailing_comma_); 117 deserializer.set_allow_trailing_comma(allow_trailing_comma_);
117 return deserializer.Deserialize(error_code, error_str); 118 return deserializer.Deserialize(error_code, error_str);
118 } 119 }
OLDNEW
« no previous file with comments | « base/json/json_file_value_serializer.h ('k') | base/json/json_string_value_serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698