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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return Remove(CreateVector(key)); | 118 return Remove(CreateVector(key)); |
119 } | 119 } |
120 | 120 |
121 ValueStore::WriteResult TestingValueStore::Remove( | 121 ValueStore::WriteResult TestingValueStore::Remove( |
122 const std::vector<std::string>& keys) { | 122 const std::vector<std::string>& keys) { |
123 write_count_++; | 123 write_count_++; |
124 if (fail_all_requests_) { | 124 if (fail_all_requests_) { |
125 return WriteResultError(); | 125 return WriteResultError(); |
126 } | 126 } |
127 | 127 |
128 scoped_ptr<ValueStoreChangeList> changes( | 128 scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList()); |
129 new ValueStoreChangeList()); | |
130 for (std::vector<std::string>::const_iterator it = keys.begin(); | 129 for (std::vector<std::string>::const_iterator it = keys.begin(); |
131 it != keys.end(); ++it) { | 130 it != keys.end(); ++it) { |
132 Value* old_value = NULL; | 131 scoped_ptr<Value> old_value; |
133 if (storage_.RemoveWithoutPathExpansion(*it, &old_value)) { | 132 if (storage_.RemoveWithoutPathExpansion(*it, &old_value)) { |
134 changes->push_back(ValueStoreChange(*it, old_value, NULL)); | 133 changes->push_back(ValueStoreChange(*it, old_value.release(), NULL)); |
135 } | 134 } |
136 } | 135 } |
137 return MakeWriteResult(changes.release()); | 136 return MakeWriteResult(changes.release()); |
138 } | 137 } |
139 | 138 |
140 ValueStore::WriteResult TestingValueStore::Clear() { | 139 ValueStore::WriteResult TestingValueStore::Clear() { |
141 std::vector<std::string> keys; | 140 std::vector<std::string> keys; |
142 for (DictionaryValue::Iterator it(storage_); !it.IsAtEnd(); it.Advance()) { | 141 for (DictionaryValue::Iterator it(storage_); !it.IsAtEnd(); it.Advance()) { |
143 keys.push_back(it.key()); | 142 keys.push_back(it.key()); |
144 } | 143 } |
145 return Remove(keys); | 144 return Remove(keys); |
146 } | 145 } |
OLD | NEW |