| 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 "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "components/invalidation/public/ack_handle.h" | 8 #include "components/invalidation/public/ack_handle.h" |
| 9 #include "components/invalidation/public/object_id_invalidation_map.h" | 9 #include "components/invalidation/public/object_id_invalidation_map.h" |
| 10 | 10 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 std::unique_ptr<base::DictionaryValue> UnackedInvalidationSet::ToValue() const { | 160 std::unique_ptr<base::DictionaryValue> UnackedInvalidationSet::ToValue() const { |
| 161 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 161 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
| 162 value->SetString(kSourceKey, base::IntToString(object_id_.source())); | 162 value->SetString(kSourceKey, base::IntToString(object_id_.source())); |
| 163 value->SetString(kNameKey, object_id_.name()); | 163 value->SetString(kNameKey, object_id_.name()); |
| 164 | 164 |
| 165 std::unique_ptr<base::ListValue> list_value(new base::ListValue); | 165 std::unique_ptr<base::ListValue> list_value(new base::ListValue); |
| 166 for (InvalidationsSet::const_iterator it = invalidations_.begin(); | 166 for (InvalidationsSet::const_iterator it = invalidations_.begin(); |
| 167 it != invalidations_.end(); ++it) { | 167 it != invalidations_.end(); ++it) { |
| 168 list_value->Append(it->ToValue().release()); | 168 list_value->Append(it->ToValue()); |
| 169 } | 169 } |
| 170 value->Set(kInvalidationListKey, list_value.release()); | 170 value->Set(kInvalidationListKey, list_value.release()); |
| 171 | 171 |
| 172 return value; | 172 return value; |
| 173 } | 173 } |
| 174 | 174 |
| 175 bool UnackedInvalidationSet::ResetFromValue( | 175 bool UnackedInvalidationSet::ResetFromValue( |
| 176 const base::DictionaryValue& value) { | 176 const base::DictionaryValue& value) { |
| 177 std::string source_str; | 177 std::string source_str; |
| 178 if (!value.GetString(kSourceKey, &source_str)) { | 178 if (!value.GetString(kSourceKey, &source_str)) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // an UnknownVersion invalidation. We remove the oldest remaining | 235 // an UnknownVersion invalidation. We remove the oldest remaining |
| 236 // invalidation to make room for it. | 236 // invalidation to make room for it. |
| 237 invalidation::ObjectId id = invalidations_.begin()->object_id(); | 237 invalidation::ObjectId id = invalidations_.begin()->object_id(); |
| 238 invalidations_.erase(*invalidations_.begin()); | 238 invalidations_.erase(*invalidations_.begin()); |
| 239 | 239 |
| 240 Invalidation unknown_version = Invalidation::InitUnknownVersion(id); | 240 Invalidation unknown_version = Invalidation::InitUnknownVersion(id); |
| 241 invalidations_.insert(unknown_version); | 241 invalidations_.insert(unknown_version); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace syncer | 244 } // namespace syncer |
| OLD | NEW |