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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 return; | 243 return; |
244 } | 244 } |
245 if (!base::ImportantFileWriter::WriteFileAtomically(store_path_, json_data)) | 245 if (!base::ImportantFileWriter::WriteFileAtomically(store_path_, json_data)) |
246 LOG(ERROR) << "Error writing RLZ store"; | 246 LOG(ERROR) << "Error writing RLZ store"; |
247 } | 247 } |
248 | 248 |
249 bool RlzValueStoreChromeOS::AddValueToList(const std::string& list_name, | 249 bool RlzValueStoreChromeOS::AddValueToList(const std::string& list_name, |
250 std::unique_ptr<base::Value> value) { | 250 std::unique_ptr<base::Value> value) { |
251 base::ListValue* list_value = NULL; | 251 base::ListValue* list_value = NULL; |
252 if (!rlz_store_->GetList(list_name, &list_value)) { | 252 if (!rlz_store_->GetList(list_name, &list_value)) { |
253 list_value = new base::ListValue; | 253 list_value = |
254 rlz_store_->Set(list_name, list_value); | 254 rlz_store_->SetList(list_name, base::MakeUnique<base::ListValue>()); |
255 } | 255 } |
256 list_value->AppendIfNotPresent(std::move(value)); | 256 list_value->AppendIfNotPresent(std::move(value)); |
257 return true; | 257 return true; |
258 } | 258 } |
259 | 259 |
260 bool RlzValueStoreChromeOS::RemoveValueFromList(const std::string& list_name, | 260 bool RlzValueStoreChromeOS::RemoveValueFromList(const std::string& list_name, |
261 const base::Value& value) { | 261 const base::Value& value) { |
262 base::ListValue* list_value = NULL; | 262 base::ListValue* list_value = NULL; |
263 if (!rlz_store_->GetList(list_name, &list_value)) | 263 if (!rlz_store_->GetList(list_name, &list_value)) |
264 return false; | 264 return false; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 g_testing_rlz_store_path.Get() = directory; | 337 g_testing_rlz_store_path.Get() = directory; |
338 } | 338 } |
339 | 339 |
340 std::string RlzStoreFilenameStr() { | 340 std::string RlzStoreFilenameStr() { |
341 return GetRlzStorePath().value(); | 341 return GetRlzStorePath().value(); |
342 } | 342 } |
343 | 343 |
344 } // namespace testing | 344 } // namespace testing |
345 | 345 |
346 } // namespace rlz_lib | 346 } // namespace rlz_lib |
OLD | NEW |