Don't enable DWM rendering policy on Windows with custom frames.
[chromium-blink-merge.git] / sync / notifier / single_object_invalidation_set.cc
blob93b47ab4d58212263ed765ef641da77a3782b1f6
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.
5 #include "sync/notifier/single_object_invalidation_set.h"
7 #include "base/values.h"
8 #include "sync/notifier/invalidation_util.h"
10 namespace syncer {
12 SingleObjectInvalidationSet::SingleObjectInvalidationSet() {}
14 SingleObjectInvalidationSet::~SingleObjectInvalidationSet() {}
16 void SingleObjectInvalidationSet::Insert(const Invalidation& invalidation) {
17 invalidations_.insert(invalidation);
20 void SingleObjectInvalidationSet::InsertAll(
21 const SingleObjectInvalidationSet& other) {
22 invalidations_.insert(other.begin(), other.end());
25 void SingleObjectInvalidationSet::Clear() {
26 invalidations_.clear();
29 void SingleObjectInvalidationSet::Erase(const_iterator it) {
30 invalidations_.erase(*it);
33 bool SingleObjectInvalidationSet::StartsWithUnknownVersion() const {
34 return !invalidations_.empty() &&
35 invalidations_.begin()->is_unknown_version();
38 size_t SingleObjectInvalidationSet::GetSize() const {
39 return invalidations_.size();
42 bool SingleObjectInvalidationSet::IsEmpty() const {
43 return invalidations_.empty();
46 namespace {
48 struct InvalidationComparator {
49 bool operator()(const Invalidation& inv1, const Invalidation& inv2) {
50 return inv1.Equals(inv2);
54 } // namespace
56 bool SingleObjectInvalidationSet::operator==(
57 const SingleObjectInvalidationSet& other) const {
58 return std::equal(invalidations_.begin(),
59 invalidations_.end(),
60 other.invalidations_.begin(),
61 InvalidationComparator());
64 SingleObjectInvalidationSet::const_iterator
65 SingleObjectInvalidationSet::begin() const {
66 return invalidations_.begin();
69 SingleObjectInvalidationSet::const_iterator
70 SingleObjectInvalidationSet::end() const {
71 return invalidations_.end();
74 SingleObjectInvalidationSet::const_reverse_iterator
75 SingleObjectInvalidationSet::rbegin() const {
76 return invalidations_.rbegin();
79 SingleObjectInvalidationSet::const_reverse_iterator
80 SingleObjectInvalidationSet::rend() const {
81 return invalidations_.rend();
84 const Invalidation& SingleObjectInvalidationSet::back() const {
85 return *invalidations_.rbegin();
88 scoped_ptr<base::ListValue> SingleObjectInvalidationSet::ToValue() const {
89 scoped_ptr<base::ListValue> value(new base::ListValue);
90 for (InvalidationsSet::const_iterator it = invalidations_.begin();
91 it != invalidations_.end(); ++it) {
92 value->Append(it->ToValue().release());
94 return value.Pass();
97 bool SingleObjectInvalidationSet::ResetFromValue(
98 const base::ListValue& list) {
99 for (size_t i = 0; i < list.GetSize(); ++i) {
100 const base::DictionaryValue* dict;
101 if (!list.GetDictionary(i, &dict)) {
102 DLOG(WARNING) << "Could not find invalidation at index " << i;
103 return false;
105 scoped_ptr<Invalidation> invalidation = Invalidation::InitFromValue(*dict);
106 if (!invalidation) {
107 DLOG(WARNING) << "Failed to parse invalidation at index " << i;
108 return false;
110 invalidations_.insert(*invalidation);
112 return true;
115 } // namespace syncer