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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « base/json/json_file_value_serializer.h ('k') | base/json/json_reader_unittest.cc » ('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/file_util.h" 7 #include "base/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 28 matching lines...) Expand all
39 if (file_util::WriteFile(json_file_path_, 39 if (file_util::WriteFile(json_file_path_,
40 json_string.data(), 40 json_string.data(),
41 data_size) != data_size) 41 data_size) != data_size)
42 return false; 42 return false;
43 43
44 return true; 44 return true;
45 } 45 }
46 46
47 int JSONFileValueSerializer::ReadFileToString(std::string* json_string) { 47 int JSONFileValueSerializer::ReadFileToString(std::string* json_string) {
48 DCHECK(json_string); 48 DCHECK(json_string);
49 if (!file_util::ReadFileToString(json_file_path_, json_string)) { 49 if (!base::ReadFileToString(json_file_path_, json_string)) {
50 #if defined(OS_WIN) 50 #if defined(OS_WIN)
51 int error = ::GetLastError(); 51 int error = ::GetLastError();
52 if (error == ERROR_SHARING_VIOLATION || error == ERROR_LOCK_VIOLATION) { 52 if (error == ERROR_SHARING_VIOLATION || error == ERROR_LOCK_VIOLATION) {
53 return JSON_FILE_LOCKED; 53 return JSON_FILE_LOCKED;
54 } else if (error == ERROR_ACCESS_DENIED) { 54 } else if (error == ERROR_ACCESS_DENIED) {
55 return JSON_ACCESS_DENIED; 55 return JSON_ACCESS_DENIED;
56 } 56 }
57 #endif 57 #endif
58 if (!base::PathExists(json_file_path_)) 58 if (!base::PathExists(json_file_path_))
59 return JSON_NO_SUCH_FILE; 59 return JSON_NO_SUCH_FILE;
(...skipping 30 matching lines...) Expand all
90 *error_code = error; 90 *error_code = error;
91 if (error_str) 91 if (error_str)
92 *error_str = GetErrorMessageForCode(error); 92 *error_str = GetErrorMessageForCode(error);
93 return NULL; 93 return NULL;
94 } 94 }
95 95
96 JSONStringValueSerializer serializer(json_string); 96 JSONStringValueSerializer serializer(json_string);
97 serializer.set_allow_trailing_comma(allow_trailing_comma_); 97 serializer.set_allow_trailing_comma(allow_trailing_comma_);
98 return serializer.Deserialize(error_code, error_str); 98 return serializer.Deserialize(error_code, error_str);
99 } 99 }
OLDNEW
« no previous file with comments | « base/json/json_file_value_serializer.h ('k') | base/json/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698