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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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_parser.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 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 case JSON_FILE_LOCKED: 94 case JSON_FILE_LOCKED:
95 return kFileLocked; 95 return kFileLocked;
96 case JSON_NO_SUCH_FILE: 96 case JSON_NO_SUCH_FILE:
97 return kNoSuchFile; 97 return kNoSuchFile;
98 default: 98 default:
99 NOTREACHED(); 99 NOTREACHED();
100 return ""; 100 return "";
101 } 101 }
102 } 102 }
103 103
104 scoped_ptr<base::Value> JSONFileValueDeserializer::Deserialize( 104 std::unique_ptr<base::Value> JSONFileValueDeserializer::Deserialize(
105 int* error_code, 105 int* error_code,
106 std::string* error_str) { 106 std::string* error_str) {
107 std::string json_string; 107 std::string json_string;
108 int error = ReadFileToString(&json_string); 108 int error = ReadFileToString(&json_string);
109 if (error != JSON_NO_ERROR) { 109 if (error != JSON_NO_ERROR) {
110 if (error_code) 110 if (error_code)
111 *error_code = error; 111 *error_code = error;
112 if (error_str) 112 if (error_str)
113 *error_str = GetErrorMessageForCode(error); 113 *error_str = GetErrorMessageForCode(error);
114 return NULL; 114 return NULL;
115 } 115 }
116 116
117 JSONStringValueDeserializer deserializer(json_string); 117 JSONStringValueDeserializer deserializer(json_string);
118 deserializer.set_allow_trailing_comma(allow_trailing_comma_); 118 deserializer.set_allow_trailing_comma(allow_trailing_comma_);
119 return deserializer.Deserialize(error_code, error_str); 119 return deserializer.Deserialize(error_code, error_str);
120 } 120 }
OLDNEW
« no previous file with comments | « base/json/json_file_value_serializer.h ('k') | base/json/json_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698