OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SYNC_NOTIFIER_SINGLE_OBJECT_INVALIDATION_SET_H_ |
| 6 #define SYNC_NOTIFIER_SINGLE_OBJECT_INVALIDATION_SET_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "sync/base/sync_export.h" |
| 12 #include "sync/internal_api/public/base/invalidation.h" |
| 13 |
| 14 namespace base { |
| 15 class ListValue; |
| 16 } // namespace base |
| 17 |
| 18 namespace syncer { |
| 19 |
| 20 struct InvalidationVersionLessThan { |
| 21 bool operator()(const Invalidation& a, const Invalidation& b); |
| 22 }; |
| 23 |
| 24 // Holds a list of invalidations that all share the same Object ID. |
| 25 // |
| 26 // The list is kept sorted by version to make it easier to perform common |
| 27 // operations, like checking for an unknown version invalidation or fetching the |
| 28 // highest invalidation with the highest version number. |
| 29 class SYNC_EXPORT SingleObjectInvalidationSet { |
| 30 public: |
| 31 typedef std::set<Invalidation, InvalidationVersionLessThan> InvalidationsSet; |
| 32 typedef InvalidationsSet::const_iterator const_iterator; |
| 33 typedef InvalidationsSet::const_reverse_iterator const_reverse_iterator; |
| 34 |
| 35 SingleObjectInvalidationSet(); |
| 36 ~SingleObjectInvalidationSet(); |
| 37 |
| 38 void Insert(const Invalidation& invalidation); |
| 39 void InsertAll(const SingleObjectInvalidationSet& other); |
| 40 void Clear(); |
| 41 |
| 42 // Returns true if this list contains an unknown version. |
| 43 // |
| 44 // Unknown version invalidations always end up at the start of the list, |
| 45 // because they have the lowest possible value in the sort ordering. |
| 46 bool StartsWithUnknownVersion() const; |
| 47 size_t GetSize() const; |
| 48 bool IsEmpty() const; |
| 49 bool operator==(const SingleObjectInvalidationSet& other) const; |
| 50 |
| 51 const_iterator begin() const; |
| 52 const_iterator end() const; |
| 53 const_reverse_iterator rbegin() const; |
| 54 const_reverse_iterator rend() const; |
| 55 const Invalidation& back() const; |
| 56 |
| 57 scoped_ptr<base::ListValue> ToValue() const; |
| 58 bool ResetFromValue(const base::ListValue& list); |
| 59 |
| 60 private: |
| 61 InvalidationsSet invalidations_; |
| 62 }; |
| 63 |
| 64 } // syncer |
| 65 |
| 66 #endif // SYNC_NOTIFIER_SINGLE_OBJECT_INVALIDATION_SET_H_ |
OLD | NEW |