| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/invalidation/impl/unacked_invalidation_set.h" | 5 #include "components/invalidation/impl/unacked_invalidation_set.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 8 #include "components/invalidation/public/ack_handle.h" | 10 #include "components/invalidation/public/ack_handle.h" |
| 9 #include "components/invalidation/public/object_id_invalidation_map.h" | 11 #include "components/invalidation/public/object_id_invalidation_map.h" |
| 10 | 12 |
| 11 namespace { | 13 namespace { |
| 12 | 14 |
| 13 const char kSourceKey[] = "source"; | 15 const char kSourceKey[] = "source"; |
| 14 const char kNameKey[] = "name"; | 16 const char kNameKey[] = "name"; |
| 15 const char kInvalidationListKey[] = "invalidation-list"; | 17 const char kInvalidationListKey[] = "invalidation-list"; |
| 16 | 18 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 std::unique_ptr<base::DictionaryValue> UnackedInvalidationSet::ToValue() const { | 162 std::unique_ptr<base::DictionaryValue> UnackedInvalidationSet::ToValue() const { |
| 161 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 163 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
| 162 value->SetString(kSourceKey, base::IntToString(object_id_.source())); | 164 value->SetString(kSourceKey, base::IntToString(object_id_.source())); |
| 163 value->SetString(kNameKey, object_id_.name()); | 165 value->SetString(kNameKey, object_id_.name()); |
| 164 | 166 |
| 165 std::unique_ptr<base::ListValue> list_value(new base::ListValue); | 167 std::unique_ptr<base::ListValue> list_value(new base::ListValue); |
| 166 for (InvalidationsSet::const_iterator it = invalidations_.begin(); | 168 for (InvalidationsSet::const_iterator it = invalidations_.begin(); |
| 167 it != invalidations_.end(); ++it) { | 169 it != invalidations_.end(); ++it) { |
| 168 list_value->Append(it->ToValue()); | 170 list_value->Append(it->ToValue()); |
| 169 } | 171 } |
| 170 value->Set(kInvalidationListKey, list_value.release()); | 172 value->Set(kInvalidationListKey, std::move(list_value)); |
| 171 | 173 |
| 172 return value; | 174 return value; |
| 173 } | 175 } |
| 174 | 176 |
| 175 bool UnackedInvalidationSet::ResetFromValue( | 177 bool UnackedInvalidationSet::ResetFromValue( |
| 176 const base::DictionaryValue& value) { | 178 const base::DictionaryValue& value) { |
| 177 std::string source_str; | 179 std::string source_str; |
| 178 if (!value.GetString(kSourceKey, &source_str)) { | 180 if (!value.GetString(kSourceKey, &source_str)) { |
| 179 DLOG(WARNING) << "Unable to deserialize source"; | 181 DLOG(WARNING) << "Unable to deserialize source"; |
| 180 return false; | 182 return false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // an UnknownVersion invalidation. We remove the oldest remaining | 237 // an UnknownVersion invalidation. We remove the oldest remaining |
| 236 // invalidation to make room for it. | 238 // invalidation to make room for it. |
| 237 invalidation::ObjectId id = invalidations_.begin()->object_id(); | 239 invalidation::ObjectId id = invalidations_.begin()->object_id(); |
| 238 invalidations_.erase(*invalidations_.begin()); | 240 invalidations_.erase(*invalidations_.begin()); |
| 239 | 241 |
| 240 Invalidation unknown_version = Invalidation::InitUnknownVersion(id); | 242 Invalidation unknown_version = Invalidation::InitUnknownVersion(id); |
| 241 invalidations_.insert(unknown_version); | 243 invalidations_.insert(unknown_version); |
| 242 } | 244 } |
| 243 | 245 |
| 244 } // namespace syncer | 246 } // namespace syncer |
| OLD | NEW |