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

Side by Side Diff: chrome/browser/value_store/testing_value_store.cc

Issue 21030009: Make element removal methods in DictionaryValue and ListValue take scoped_ptr's as outparams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/about_ui.cc ('k') | chrome/browser/value_store/value_store_frontend.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/about_ui.cc ('k') | chrome/browser/value_store/value_store_frontend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698