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

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

Issue 1446363003: Deleted OS_WIN and all Windows specific files from base. (Closed) Base URL: https://github.com/domokit/mojo.git@base_tests
Patch Set: Created 5 years, 1 month 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/i18n/rtl.cc ('k') | base/json/json_value_serializer_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/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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 allow_trailing_comma_(false), 57 allow_trailing_comma_(false),
58 last_read_size_(0U) { 58 last_read_size_(0U) {
59 } 59 }
60 60
61 JSONFileValueDeserializer::~JSONFileValueDeserializer() { 61 JSONFileValueDeserializer::~JSONFileValueDeserializer() {
62 } 62 }
63 63
64 int JSONFileValueDeserializer::ReadFileToString(std::string* json_string) { 64 int JSONFileValueDeserializer::ReadFileToString(std::string* json_string) {
65 DCHECK(json_string); 65 DCHECK(json_string);
66 if (!base::ReadFileToString(json_file_path_, json_string)) { 66 if (!base::ReadFileToString(json_file_path_, json_string)) {
67 #if defined(OS_WIN)
68 int error = ::GetLastError();
69 if (error == ERROR_SHARING_VIOLATION || error == ERROR_LOCK_VIOLATION) {
70 return JSON_FILE_LOCKED;
71 } else if (error == ERROR_ACCESS_DENIED) {
72 return JSON_ACCESS_DENIED;
73 }
74 #endif
75 if (!base::PathExists(json_file_path_)) 67 if (!base::PathExists(json_file_path_))
76 return JSON_NO_SUCH_FILE; 68 return JSON_NO_SUCH_FILE;
77 else 69 else
78 return JSON_CANNOT_READ_FILE; 70 return JSON_CANNOT_READ_FILE;
79 } 71 }
80 72
81 last_read_size_ = json_string->size(); 73 last_read_size_ = json_string->size();
82 return JSON_NO_ERROR; 74 return JSON_NO_ERROR;
83 } 75 }
84 76
(...skipping 24 matching lines...) Expand all
109 *error_code = error; 101 *error_code = error;
110 if (error_str) 102 if (error_str)
111 *error_str = GetErrorMessageForCode(error); 103 *error_str = GetErrorMessageForCode(error);
112 return NULL; 104 return NULL;
113 } 105 }
114 106
115 JSONStringValueDeserializer deserializer(json_string); 107 JSONStringValueDeserializer deserializer(json_string);
116 deserializer.set_allow_trailing_comma(allow_trailing_comma_); 108 deserializer.set_allow_trailing_comma(allow_trailing_comma_);
117 return deserializer.Deserialize(error_code, error_str); 109 return deserializer.Deserialize(error_code, error_str);
118 } 110 }
OLDNEW
« no previous file with comments | « base/i18n/rtl.cc ('k') | base/json/json_value_serializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698