| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sync/notifier/unacked_invalidation_set.h" | 5 #include "sync/notifier/unacked_invalidation_set.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "sync/internal_api/public/base/ack_handle.h" | 8 #include "sync/internal_api/public/base/ack_handle.h" |
| 9 #include "sync/notifier/object_id_invalidation_map.h" | 9 #include "sync/notifier/object_id_invalidation_map.h" |
| 10 #include "sync/notifier/sync_invalidation_listener.h" | |
| 11 | 10 |
| 12 namespace { | 11 namespace { |
| 13 | 12 |
| 14 const char kSourceKey[] = "source"; | 13 const char kSourceKey[] = "source"; |
| 15 const char kNameKey[] = "name"; | 14 const char kNameKey[] = "name"; |
| 16 const char kInvalidationListKey[] = "invalidation-list"; | 15 const char kInvalidationListKey[] = "invalidation-list"; |
| 17 | 16 |
| 18 } // namespace | 17 } // namespace |
| 19 | 18 |
| 20 namespace syncer { | 19 namespace syncer { |
| 21 | 20 |
| 22 const size_t UnackedInvalidationSet::kMaxBufferedInvalidations = 5; | 21 const size_t UnackedInvalidationSet::kMaxBufferedInvalidations = 5; |
| 23 | 22 |
| 24 // static | 23 // static |
| 25 UnackedInvalidationSet::UnackedInvalidationSet( | 24 UnackedInvalidationSet::UnackedInvalidationSet( |
| 26 invalidation::ObjectId id) | 25 invalidation::ObjectId id) |
| 27 : registered_(false), | 26 : registered_(false), |
| 28 object_id_(id) {} | 27 object_id_(id) {} |
| 29 | 28 |
| 29 UnackedInvalidationSet::UnackedInvalidationSet( |
| 30 const UnackedInvalidationSet& other) |
| 31 : registered_(other.registered_), |
| 32 object_id_(other.object_id_), |
| 33 invalidations_(other.invalidations_) { |
| 34 } |
| 35 |
| 30 UnackedInvalidationSet::~UnackedInvalidationSet() {} | 36 UnackedInvalidationSet::~UnackedInvalidationSet() {} |
| 31 | 37 |
| 32 const invalidation::ObjectId& UnackedInvalidationSet::object_id() const { | 38 const invalidation::ObjectId& UnackedInvalidationSet::object_id() const { |
| 33 return object_id_; | 39 return object_id_; |
| 34 } | 40 } |
| 35 | 41 |
| 36 void UnackedInvalidationSet::Add( | 42 void UnackedInvalidationSet::Add( |
| 37 const Invalidation& invalidation) { | 43 const Invalidation& invalidation) { |
| 38 SingleObjectInvalidationSet set; | 44 SingleObjectInvalidationSet set; |
| 39 set.Insert(invalidation); | 45 set.Insert(invalidation); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // an UnknownVersion invalidation. We remove the oldest remaining | 201 // an UnknownVersion invalidation. We remove the oldest remaining |
| 196 // invalidation to make room for it. | 202 // invalidation to make room for it. |
| 197 invalidation::ObjectId id = invalidations_.begin()->object_id(); | 203 invalidation::ObjectId id = invalidations_.begin()->object_id(); |
| 198 invalidations_.erase(*invalidations_.begin()); | 204 invalidations_.erase(*invalidations_.begin()); |
| 199 | 205 |
| 200 Invalidation unknown_version = Invalidation::InitUnknownVersion(id); | 206 Invalidation unknown_version = Invalidation::InitUnknownVersion(id); |
| 201 invalidations_.insert(unknown_version); | 207 invalidations_.insert(unknown_version); |
| 202 } | 208 } |
| 203 | 209 |
| 204 } // namespace syncer | 210 } // namespace syncer |
| OLD | NEW |