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

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: 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
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 V4Store::Destroy(std::move((*store_map_)[identifier]));
145 (*store_map_)[identifier] = std::move(new_store); 146 (*store_map_)[identifier] = std::move(new_store);
Scott Hess - ex-Googler 2016/10/18 02:57:01 Does this work? I mean, I think it probably does,
Scott Hess - ex-Googler 2016/10/18 02:57:55 Or, of course: (*store_map_)[identifier].swap(new
146 } 147 }
147 148
148 pending_store_updates_--; 149 pending_store_updates_--;
149 if (!pending_store_updates_) { 150 if (!pending_store_updates_) {
150 db_updated_callback_.Run(); 151 db_updated_callback_.Run();
151 db_updated_callback_.Reset(); 152 db_updated_callback_.Reset();
152 } 153 }
153 } 154 }
154 155
155 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() { 156 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 filename_(filename), 221 filename_(filename),
221 list_id_(list_id), 222 list_id_(list_id),
222 sb_threat_type_(sb_threat_type) { 223 sb_threat_type_(sb_threat_type) {
223 DCHECK(!fetch_updates_ || !filename_.empty()); 224 DCHECK(!fetch_updates_ || !filename_.empty());
224 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_); 225 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_);
225 } 226 }
226 227
227 ListInfo::~ListInfo() {} 228 ListInfo::~ListInfo() {}
228 229
229 } // namespace safe_browsing 230 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_store.h » ('j') | components/safe_browsing_db/v4_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698