Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1885)

Unified Diff: sync/notifier/ordered_invalidation_list.h

Issue 23441042: Refactor common invalidation framework types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/notifier/ordered_invalidation_list.h
diff --git a/sync/notifier/ordered_invalidation_list.h b/sync/notifier/ordered_invalidation_list.h
new file mode 100644
index 0000000000000000000000000000000000000000..5985f0aac3270295c0dcfd5dd49bee4fa6e9ad9a
--- /dev/null
+++ b/sync/notifier/ordered_invalidation_list.h
@@ -0,0 +1,66 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_LIST_H_
+#define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_LIST_H_
+
+#include <set>
+
+#include "base/memory/scoped_ptr.h"
+#include "sync/base/sync_export.h"
+#include "sync/internal_api/public/base/invalidation.h"
+
+namespace base {
+class ListValue;
+} // namespace base
+
+namespace syncer {
+
+struct InvalidationVersionLessThan {
+ bool operator()(const Invalidation& a, const Invalidation& b);
+};
+
+// Holds a list of invalidations that all share the same Object ID.
+//
+// The list is kept sorted by version to make it easier to perform common
+// operations, like checking for an unknown version invalidation or fetching the
+// highest invalidation with the highest version number.
+class SYNC_EXPORT OrderedInvalidationList {
+ public:
+ typedef std::set<Invalidation, InvalidationVersionLessThan> InvalidationsSet;
+ typedef InvalidationsSet::const_iterator const_iterator;
+ typedef InvalidationsSet::const_reverse_iterator const_reverse_iterator;
+
+ OrderedInvalidationList();
+ ~OrderedInvalidationList();
+
+ void Insert(const Invalidation& invalidation);
+ void InsertAll(const OrderedInvalidationList& other);
+ void Clear();
+
+ // Returns true if this list contains an unknown version.
+ //
+ // Unknown version invalidations always end up at the start of the list,
+ // because they have the lowest possible value in the sort ordering.
+ bool StartsWithUnknownVersion() const;
+ size_t GetSize() const;
+ bool IsEmpty() const;
+ bool operator==(const OrderedInvalidationList& other) const;
+
+ const_iterator begin() const;
+ const_iterator end() const;
+ const_reverse_iterator rbegin() const;
+ const_reverse_iterator rend() const;
+ const Invalidation& back() const;
+
+ scoped_ptr<base::ListValue> ToValue() const;
+ bool ResetFromValue(const base::ListValue& list);
+
+ private:
+ InvalidationsSet invalidations_;
+};
+
+} // syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_LIST_H_

Powered by Google App Engine
This is Rietveld 408576698