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

Side by Side Diff: content/browser/leveldb_wrapper_impl.cc

Issue 2697953002: Remove incorrect optimization in LevelDBWrapperImpl::DeleteAll(). (Closed)
Patch Set: fix web platform test Created 3 years, 10 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
« no previous file with comments | « no previous file | content/browser/leveldb_wrapper_impl_unittest.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/leveldb_wrapper_impl.h" 5 #include "content/browser/leveldb_wrapper_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "components/leveldb/public/cpp/util.h" 10 #include "components/leveldb/public/cpp/util.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 bytes_used_ -= key.size() + old_value.size(); 179 bytes_used_ -= key.size() + old_value.size();
180 observers_.ForAllPtrs( 180 observers_.ForAllPtrs(
181 [&key, &source, &old_value](mojom::LevelDBObserver* observer) { 181 [&key, &source, &old_value](mojom::LevelDBObserver* observer) {
182 observer->KeyDeleted(key, old_value, source); 182 observer->KeyDeleted(key, old_value, source);
183 }); 183 });
184 callback.Run(true); 184 callback.Run(true);
185 } 185 }
186 186
187 void LevelDBWrapperImpl::DeleteAll(const std::string& source, 187 void LevelDBWrapperImpl::DeleteAll(const std::string& source,
188 const DeleteAllCallback& callback) { 188 const DeleteAllCallback& callback) {
189 if (!map_ && !on_load_complete_tasks_.empty()) { 189 if (!map_) {
190 LoadMap( 190 LoadMap(
191 base::Bind(&LevelDBWrapperImpl::DeleteAll, base::Unretained(this), 191 base::Bind(&LevelDBWrapperImpl::DeleteAll, base::Unretained(this),
192 source, callback)); 192 source, callback));
193 return; 193 return;
194 } 194 }
195 195
196 if (database_ && (!map_ || !map_->empty())) { 196 if (map_->empty()) {
197 callback.Run(true);
198 return;
199 }
200
201 if (database_) {
197 CreateCommitBatchIfNeeded(); 202 CreateCommitBatchIfNeeded();
198 commit_batch_->clear_all_first = true; 203 commit_batch_->clear_all_first = true;
199 commit_batch_->changed_keys.clear(); 204 commit_batch_->changed_keys.clear();
200 } 205 }
201 if (!map_)
202 map_.reset(new ValueMap);
203 206
204 map_->clear(); 207 map_->clear();
205 bytes_used_ = 0; 208 bytes_used_ = 0;
206 observers_.ForAllPtrs( 209 observers_.ForAllPtrs(
207 [&source](mojom::LevelDBObserver* observer) { 210 [&source](mojom::LevelDBObserver* observer) {
208 observer->AllDeleted(source); 211 observer->AllDeleted(source);
209 }); 212 });
210 callback.Run(true); 213 callback.Run(true);
211 } 214 }
212 215
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 weak_ptr_factory_.GetWeakPtr())); 426 weak_ptr_factory_.GetWeakPtr()));
424 } 427 }
425 428
426 void LevelDBWrapperImpl::OnCommitComplete(leveldb::mojom::DatabaseError error) { 429 void LevelDBWrapperImpl::OnCommitComplete(leveldb::mojom::DatabaseError error) {
427 --commit_batches_in_flight_; 430 --commit_batches_in_flight_;
428 StartCommitTimer(); 431 StartCommitTimer();
429 delegate_->DidCommit(error); 432 delegate_->DidCommit(error);
430 } 433 }
431 434
432 } // namespace content 435 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/leveldb_wrapper_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698