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

Side by Side Diff: components/safe_browsing_db/v4_database.cc

Issue 2425703004: Destroy store on task runner. That's where all store operations happen. (Closed)
Patch Set: shess@feedback. WaitForTasksOnTaskRunner at the end of the test that calls ApplyUpdate and expects … Created 4 years, 2 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 | components/safe_browsing_db/v4_database_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 <memory> 5 #include <memory>
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 current_task_runner->PostTask(FROM_HERE, db_updated_callback_); 135 current_task_runner->PostTask(FROM_HERE, db_updated_callback_);
136 db_updated_callback_.Reset(); 136 db_updated_callback_.Reset();
137 } 137 }
138 } 138 }
139 139
140 void V4Database::UpdatedStoreReady(ListIdentifier identifier, 140 void V4Database::UpdatedStoreReady(ListIdentifier identifier,
141 std::unique_ptr<V4Store> new_store) { 141 std::unique_ptr<V4Store> new_store) {
142 DCHECK_CURRENTLY_ON(BrowserThread::IO); 142 DCHECK_CURRENTLY_ON(BrowserThread::IO);
143 DCHECK(pending_store_updates_); 143 DCHECK(pending_store_updates_);
144 if (new_store) { 144 if (new_store) {
145 (*store_map_)[identifier] = std::move(new_store); 145 (*store_map_)[identifier].swap(new_store);
146 // |new_store| now is the store that needs to be destroyed on task runner.
147 V4Store::Destroy(std::move(new_store));
146 } 148 }
147 149
148 pending_store_updates_--; 150 pending_store_updates_--;
149 if (!pending_store_updates_) { 151 if (!pending_store_updates_) {
150 db_updated_callback_.Run(); 152 db_updated_callback_.Run();
151 db_updated_callback_.Reset(); 153 db_updated_callback_.Reset();
152 } 154 }
153 } 155 }
154 156
155 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() { 157 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 filename_(filename), 222 filename_(filename),
221 list_id_(list_id), 223 list_id_(list_id),
222 sb_threat_type_(sb_threat_type) { 224 sb_threat_type_(sb_threat_type) {
223 DCHECK(!fetch_updates_ || !filename_.empty()); 225 DCHECK(!fetch_updates_ || !filename_.empty());
224 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_); 226 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_);
225 } 227 }
226 228
227 ListInfo::~ListInfo() {} 229 ListInfo::~ListInfo() {}
228 230
229 } // namespace safe_browsing 231 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698