OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/value_store/testing_value_store.h" | 5 #include "chrome/browser/value_store/testing_value_store.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 ValueStore::WriteResult TestingValueStore::Set( | 92 ValueStore::WriteResult TestingValueStore::Set( |
93 WriteOptions options, const DictionaryValue& settings) { | 93 WriteOptions options, const DictionaryValue& settings) { |
94 if (fail_all_requests_) { | 94 if (fail_all_requests_) { |
95 return WriteResultError(); | 95 return WriteResultError(); |
96 } | 96 } |
97 | 97 |
98 scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList()); | 98 scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList()); |
99 for (DictionaryValue::Iterator it(settings); it.HasNext(); it.Advance()) { | 99 for (DictionaryValue::Iterator it(settings); it.HasNext(); it.Advance()) { |
100 Value* old_value = NULL; | 100 Value* old_value = NULL; |
101 storage_.GetWithoutPathExpansion(it.key(), &old_value); | 101 if (!storage_.GetWithoutPathExpansion(it.key(), &old_value) || |
102 if (!old_value || !old_value->Equals(&it.value())) { | 102 !old_value->Equals(&it.value())) { |
103 changes->push_back( | 103 changes->push_back( |
104 ValueStoreChange( | 104 ValueStoreChange( |
105 it.key(), | 105 it.key(), |
106 old_value ? old_value->DeepCopy() : old_value, | 106 old_value ? old_value->DeepCopy() : old_value, |
107 it.value().DeepCopy())); | 107 it.value().DeepCopy())); |
108 storage_.SetWithoutPathExpansion(it.key(), it.value().DeepCopy()); | 108 storage_.SetWithoutPathExpansion(it.key(), it.value().DeepCopy()); |
109 } | 109 } |
110 } | 110 } |
111 return MakeWriteResult(changes.release()); | 111 return MakeWriteResult(changes.release()); |
112 } | 112 } |
(...skipping 24 matching lines...) Expand all Loading... |
137 if (fail_all_requests_) { | 137 if (fail_all_requests_) { |
138 return WriteResultError(); | 138 return WriteResultError(); |
139 } | 139 } |
140 | 140 |
141 std::vector<std::string> keys; | 141 std::vector<std::string> keys; |
142 for (DictionaryValue::Iterator it(storage_); it.HasNext(); it.Advance()) { | 142 for (DictionaryValue::Iterator it(storage_); it.HasNext(); it.Advance()) { |
143 keys.push_back(it.key()); | 143 keys.push_back(it.key()); |
144 } | 144 } |
145 return Remove(keys); | 145 return Remove(keys); |
146 } | 146 } |
OLD | NEW |