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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
232 JSONStringValueSerializer serializer(&json_data); | 232 JSONStringValueSerializer serializer(&json_data); |
233 serializer.set_pretty_print(true); | 233 serializer.set_pretty_print(true); |
234 scoped_ptr<base::DictionaryValue> copy( | 234 scoped_ptr<base::DictionaryValue> copy = |
235 rlz_store_->DeepCopyWithoutEmptyChildren()); | 235 rlz_store_->DeepCopyWithoutEmptyChildren(); |
236 if (!serializer.Serialize(*copy.get())) { | 236 if (!serializer.Serialize(*copy.get())) { |
237 LOG(ERROR) << "Failed to serialize RLZ data"; | 237 LOG(ERROR) << "Failed to serialize RLZ data"; |
238 NOTREACHED(); | 238 NOTREACHED(); |
239 return; | 239 return; |
240 } | 240 } |
241 if (!base::ImportantFileWriter::WriteFileAtomically(store_path_, json_data)) | 241 if (!base::ImportantFileWriter::WriteFileAtomically(store_path_, json_data)) |
242 LOG(ERROR) << "Error writing RLZ store"; | 242 LOG(ERROR) << "Error writing RLZ store"; |
243 } | 243 } |
244 | 244 |
245 bool RlzValueStoreChromeOS::AddValueToList(std::string list_name, | 245 bool RlzValueStoreChromeOS::AddValueToList(std::string list_name, |
(...skipping 87 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 |