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

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

Issue 2889683003: Rename TaskRunner::RunsTasksOnCurrentThread() in //components (Closed)
Patch Set: rebase Created 3 years, 6 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/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 // static 74 // static
75 void V4Database::CreateOnTaskRunner( 75 void V4Database::CreateOnTaskRunner(
76 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 76 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
77 const base::FilePath& base_path, 77 const base::FilePath& base_path,
78 const ListInfos& list_infos, 78 const ListInfos& list_infos,
79 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, 79 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner,
80 NewDatabaseReadyCallback new_db_callback, 80 NewDatabaseReadyCallback new_db_callback,
81 const TimeTicks create_start_time) { 81 const TimeTicks create_start_time) {
82 DCHECK(db_task_runner->RunsTasksOnCurrentThread()); 82 DCHECK(db_task_runner->RunsTasksInCurrentSequence());
83 83
84 if (!g_store_factory.Get()) 84 if (!g_store_factory.Get())
85 g_store_factory.Get() = base::MakeUnique<V4StoreFactory>(); 85 g_store_factory.Get() = base::MakeUnique<V4StoreFactory>();
86 86
87 if (!base::CreateDirectory(base_path)) 87 if (!base::CreateDirectory(base_path))
88 NOTREACHED(); 88 NOTREACHED();
89 89
90 std::unique_ptr<StoreMap> store_map = base::MakeUnique<StoreMap>(); 90 std::unique_ptr<StoreMap> store_map = base::MakeUnique<StoreMap>();
91 for (const auto& it : list_infos) { 91 for (const auto& it : list_infos) {
92 if (!it.fetch_updates()) { 92 if (!it.fetch_updates()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 g_store_factory.Get() = std::move(factory); 126 g_store_factory.Get() = std::move(factory);
127 } 127 }
128 128
129 V4Database::V4Database( 129 V4Database::V4Database(
130 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 130 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
131 std::unique_ptr<StoreMap> store_map) 131 std::unique_ptr<StoreMap> store_map)
132 : store_map_(std::move(store_map)), 132 : store_map_(std::move(store_map)),
133 db_task_runner_(db_task_runner), 133 db_task_runner_(db_task_runner),
134 pending_store_updates_(0), 134 pending_store_updates_(0),
135 weak_factory_on_io_(this) { 135 weak_factory_on_io_(this) {
136 DCHECK(db_task_runner->RunsTasksOnCurrentThread()); 136 DCHECK(db_task_runner->RunsTasksInCurrentSequence());
137 } 137 }
138 138
139 // static 139 // static
140 void V4Database::Destroy(std::unique_ptr<V4Database> v4_database) { 140 void V4Database::Destroy(std::unique_ptr<V4Database> v4_database) {
141 DCHECK_CURRENTLY_ON(BrowserThread::IO); 141 DCHECK_CURRENTLY_ON(BrowserThread::IO);
142 V4Database* v4_database_raw = v4_database.release(); 142 V4Database* v4_database_raw = v4_database.release();
143 if (v4_database_raw) { 143 if (v4_database_raw) {
144 v4_database_raw->weak_factory_on_io_.InvalidateWeakPtrs(); 144 v4_database_raw->weak_factory_on_io_.InvalidateWeakPtrs();
145 v4_database_raw->db_task_runner_->DeleteSoon(FROM_HERE, v4_database_raw); 145 v4_database_raw->db_task_runner_->DeleteSoon(FROM_HERE, v4_database_raw);
146 } 146 }
147 } 147 }
148 148
149 V4Database::~V4Database() { 149 V4Database::~V4Database() {
150 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); 150 DCHECK(db_task_runner_->RunsTasksInCurrentSequence());
151 } 151 }
152 152
153 void V4Database::ApplyUpdate( 153 void V4Database::ApplyUpdate(
154 std::unique_ptr<ParsedServerResponse> parsed_server_response, 154 std::unique_ptr<ParsedServerResponse> parsed_server_response,
155 DatabaseUpdatedCallback db_updated_callback) { 155 DatabaseUpdatedCallback db_updated_callback) {
156 DCHECK_CURRENTLY_ON(BrowserThread::IO); 156 DCHECK_CURRENTLY_ON(BrowserThread::IO);
157 DCHECK(!pending_store_updates_); 157 DCHECK(!pending_store_updates_);
158 DCHECK(db_updated_callback_.is_null()); 158 DCHECK(db_updated_callback_.is_null());
159 159
160 db_updated_callback_ = db_updated_callback; 160 db_updated_callback_ = db_updated_callback;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 filename_(filename), 315 filename_(filename),
316 list_id_(list_id), 316 list_id_(list_id),
317 sb_threat_type_(sb_threat_type) { 317 sb_threat_type_(sb_threat_type) {
318 DCHECK(!fetch_updates_ || !filename_.empty()); 318 DCHECK(!fetch_updates_ || !filename_.empty());
319 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_); 319 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_);
320 } 320 }
321 321
322 ListInfo::~ListInfo() {} 322 ListInfo::~ListInfo() {}
323 323
324 } // namespace safe_browsing 324 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_ios.mm ('k') | components/safe_browsing_db/v4_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698