OLD | NEW |
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 "rlz/chromeos/lib/rlz_value_store_chromeos.h" | 5 #include "rlz/chromeos/lib/rlz_value_store_chromeos.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/important_file_writer.h" | 9 #include "base/files/important_file_writer.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 void RlzValueStoreChromeOS::CollectGarbage() { | 206 void RlzValueStoreChromeOS::CollectGarbage() { |
207 DCHECK(CalledOnValidThread()); | 207 DCHECK(CalledOnValidThread()); |
208 NOTIMPLEMENTED(); | 208 NOTIMPLEMENTED(); |
209 } | 209 } |
210 | 210 |
211 void RlzValueStoreChromeOS::ReadStore() { | 211 void RlzValueStoreChromeOS::ReadStore() { |
212 int error_code = 0; | 212 int error_code = 0; |
213 std::string error_msg; | 213 std::string error_msg; |
214 JSONFileValueSerializer serializer(store_path_); | 214 JSONFileValueDeserializer deserializer(store_path_); |
215 scoped_ptr<base::Value> value( | 215 scoped_ptr<base::Value> value( |
216 serializer.Deserialize(&error_code, &error_msg)); | 216 deserializer.Deserialize(&error_code, &error_msg)); |
217 switch (error_code) { | 217 switch (error_code) { |
218 case JSONFileValueSerializer::JSON_NO_SUCH_FILE: | 218 case JSONFileValueDeserializer::JSON_NO_SUCH_FILE: |
219 read_only_ = false; | 219 read_only_ = false; |
220 break; | 220 break; |
221 case JSONFileValueSerializer::JSON_NO_ERROR: | 221 case JSONFileValueDeserializer::JSON_NO_ERROR: |
222 read_only_ = false; | 222 read_only_ = false; |
223 rlz_store_.reset(static_cast<base::DictionaryValue*>(value.release())); | 223 rlz_store_.reset(static_cast<base::DictionaryValue*>(value.release())); |
224 break; | 224 break; |
225 default: | 225 default: |
226 LOG(ERROR) << "Error reading RLZ store: " << error_msg; | 226 LOG(ERROR) << "Error reading RLZ store: " << error_msg; |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 void RlzValueStoreChromeOS::WriteStore() { | 230 void RlzValueStoreChromeOS::WriteStore() { |
231 std::string json_data; | 231 std::string json_data; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 g_testing_rlz_store_path_ = directory; | 333 g_testing_rlz_store_path_ = directory; |
334 } | 334 } |
335 | 335 |
336 std::string RlzStoreFilenameStr() { | 336 std::string RlzStoreFilenameStr() { |
337 return GetRlzStorePath().value(); | 337 return GetRlzStorePath().value(); |
338 } | 338 } |
339 | 339 |
340 } // namespace testing | 340 } // namespace testing |
341 | 341 |
342 } // namespace rlz_lib | 342 } // namespace rlz_lib |
OLD | NEW |