| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/important_file_writer.h" | 8 #include "base/files/important_file_writer.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 bool RlzValueStoreChromeOS::ClearAccessPointRlz(AccessPoint access_point) { | 134 bool RlzValueStoreChromeOS::ClearAccessPointRlz(AccessPoint access_point) { |
| 135 DCHECK(CalledOnValidThread()); | 135 DCHECK(CalledOnValidThread()); |
| 136 rlz_store_->Remove(GetKeyName(kAccessPointKey, access_point), NULL); | 136 rlz_store_->Remove(GetKeyName(kAccessPointKey, access_point), NULL); |
| 137 return true; | 137 return true; |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool RlzValueStoreChromeOS::AddProductEvent(Product product, | 140 bool RlzValueStoreChromeOS::AddProductEvent(Product product, |
| 141 const char* event_rlz) { | 141 const char* event_rlz) { |
| 142 DCHECK(CalledOnValidThread()); | 142 DCHECK(CalledOnValidThread()); |
| 143 return AddValueToList(GetKeyName(kProductEventKey, product), | 143 return AddValueToList(GetKeyName(kProductEventKey, product), |
| 144 base::Value::CreateStringValue(event_rlz)); | 144 new base::StringValue(event_rlz)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool RlzValueStoreChromeOS::ReadProductEvents( | 147 bool RlzValueStoreChromeOS::ReadProductEvents( |
| 148 Product product, | 148 Product product, |
| 149 std::vector<std::string>* events) { | 149 std::vector<std::string>* events) { |
| 150 DCHECK(CalledOnValidThread()); | 150 DCHECK(CalledOnValidThread()); |
| 151 base::ListValue* events_list = NULL; ; | 151 base::ListValue* events_list = NULL; ; |
| 152 if (!rlz_store_->GetList(GetKeyName(kProductEventKey, product), &events_list)) | 152 if (!rlz_store_->GetList(GetKeyName(kProductEventKey, product), &events_list)) |
| 153 return false; | 153 return false; |
| 154 events->clear(); | 154 events->clear(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 bool RlzValueStoreChromeOS::ClearAllProductEvents(Product product) { | 171 bool RlzValueStoreChromeOS::ClearAllProductEvents(Product product) { |
| 172 DCHECK(CalledOnValidThread()); | 172 DCHECK(CalledOnValidThread()); |
| 173 rlz_store_->Remove(GetKeyName(kProductEventKey, product), NULL); | 173 rlz_store_->Remove(GetKeyName(kProductEventKey, product), NULL); |
| 174 return true; | 174 return true; |
| 175 } | 175 } |
| 176 | 176 |
| 177 bool RlzValueStoreChromeOS::AddStatefulEvent(Product product, | 177 bool RlzValueStoreChromeOS::AddStatefulEvent(Product product, |
| 178 const char* event_rlz) { | 178 const char* event_rlz) { |
| 179 DCHECK(CalledOnValidThread()); | 179 DCHECK(CalledOnValidThread()); |
| 180 return AddValueToList(GetKeyName(kStatefulEventKey, product), | 180 return AddValueToList(GetKeyName(kStatefulEventKey, product), |
| 181 base::Value::CreateStringValue(event_rlz)); | 181 new base::StringValue(event_rlz)); |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool RlzValueStoreChromeOS::IsStatefulEvent(Product product, | 184 bool RlzValueStoreChromeOS::IsStatefulEvent(Product product, |
| 185 const char* event_rlz) { | 185 const char* event_rlz) { |
| 186 DCHECK(CalledOnValidThread()); | 186 DCHECK(CalledOnValidThread()); |
| 187 base::StringValue event_value(event_rlz); | 187 base::StringValue event_value(event_rlz); |
| 188 base::ListValue* events_list = NULL; | 188 base::ListValue* events_list = NULL; |
| 189 return rlz_store_->GetList(GetKeyName(kStatefulEventKey, product), | 189 return rlz_store_->GetList(GetKeyName(kStatefulEventKey, product), |
| 190 &events_list) && | 190 &events_list) && |
| 191 events_list->Find(event_value) != events_list->end(); | 191 events_list->Find(event_value) != events_list->end(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 g_testing_rlz_store_path_ = directory; | 327 g_testing_rlz_store_path_ = directory; |
| 328 } | 328 } |
| 329 | 329 |
| 330 std::string RlzStoreFilenameStr() { | 330 std::string RlzStoreFilenameStr() { |
| 331 return GetRlzStorePath().value(); | 331 return GetRlzStorePath().value(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 } // namespace testing | 334 } // namespace testing |
| 335 | 335 |
| 336 } // namespace rlz_lib | 336 } // namespace rlz_lib |
| OLD | NEW |