| Index: components/safe_browsing_db/v4_local_database_manager.cc
|
| diff --git a/components/safe_browsing_db/v4_local_database_manager.cc b/components/safe_browsing_db/v4_local_database_manager.cc
|
| index 65916ba8ea63a77a7d0be73760239c84bef4e02a..aca22fcfbd768f4251b5aadbbf438846fe7ddaa0 100644
|
| --- a/components/safe_browsing_db/v4_local_database_manager.cc
|
| +++ b/components/safe_browsing_db/v4_local_database_manager.cc
|
| @@ -26,6 +26,8 @@ const ThreatSeverity kLeastSeverity =
|
| std::numeric_limits<ThreatSeverity>::max();
|
|
|
| ListInfos GetListInfos() {
|
| + // NOTE(vakh): When adding a store here, add the corresponding store-specific
|
| + // histograms also.
|
| return ListInfos(
|
| {ListInfo(true, "UrlMalware.store", GetUrlMalwareId(),
|
| SB_THREAT_TYPE_URL_MALWARE),
|
| @@ -79,7 +81,10 @@ scoped_refptr<V4LocalDatabaseManager> V4LocalDatabaseManager::Create(
|
| }
|
|
|
| V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path)
|
| - : base_path_(base_path), enabled_(false), list_infos_(GetListInfos()) {
|
| + : base_path_(base_path),
|
| + enabled_(false),
|
| + list_infos_(GetListInfos()),
|
| + weak_factory_(this) {
|
| DCHECK(!base_path_.empty());
|
| DCHECK(!list_infos_.empty());
|
|
|
| @@ -149,7 +154,13 @@ bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) {
|
| return true;
|
| }
|
|
|
| - PerformFullHashCheck(std::move(check), full_hash_to_store_and_hash_prefixes);
|
| + // Post the task to check full hashes back on the IO thread to follow the
|
| + // documented behavior of CheckBrowseUrl.
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&V4LocalDatabaseManager::PerformFullHashCheck, this,
|
| + base::Passed(std::move(check)),
|
| + full_hash_to_store_and_hash_prefixes));
|
| return false;
|
| }
|
|
|
| @@ -239,7 +250,7 @@ void V4LocalDatabaseManager::StartOnIOThread(
|
| SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config);
|
|
|
| db_updated_callback_ = base::Bind(&V4LocalDatabaseManager::DatabaseUpdated,
|
| - base::Unretained(this));
|
| + weak_factory_.GetWeakPtr());
|
|
|
| SetupUpdateProtocolManager(request_context_getter, config);
|
| SetupDatabase();
|
| @@ -289,7 +300,7 @@ void V4LocalDatabaseManager::DatabaseReadyForChecks(
|
| // database updates.
|
| v4_database_->VerifyChecksum(
|
| base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates,
|
| - base::Unretained(this)));
|
| + weak_factory_.GetWeakPtr()));
|
|
|
| ProcessQueuedChecks();
|
| } else {
|
| @@ -424,7 +435,7 @@ void V4LocalDatabaseManager::PerformFullHashCheck(
|
| v4_get_hash_protocol_manager_->GetFullHashes(
|
| full_hash_to_store_and_hash_prefixes,
|
| base::Bind(&V4LocalDatabaseManager::OnFullHashResponse,
|
| - base::Unretained(this), base::Passed(std::move(check))));
|
| + weak_factory_.GetWeakPtr(), base::Passed(std::move(check))));
|
| }
|
|
|
| void V4LocalDatabaseManager::ProcessQueuedChecks() {
|
| @@ -472,16 +483,18 @@ void V4LocalDatabaseManager::SetupDatabase() {
|
| // Do not create the database on the IO thread since this may be an expensive
|
| // operation. Instead, do that on the task_runner and when the new database
|
| // has been created, swap it out on the IO thread.
|
| - NewDatabaseReadyCallback db_ready_callback = base::Bind(
|
| - &V4LocalDatabaseManager::DatabaseReadyForChecks, base::Unretained(this));
|
| + NewDatabaseReadyCallback db_ready_callback =
|
| + base::Bind(&V4LocalDatabaseManager::DatabaseReadyForChecks,
|
| + weak_factory_.GetWeakPtr());
|
| V4Database::Create(task_runner_, base_path_, list_infos_, db_ready_callback);
|
| }
|
|
|
| void V4LocalDatabaseManager::SetupUpdateProtocolManager(
|
| net::URLRequestContextGetter* request_context_getter,
|
| const V4ProtocolConfig& config) {
|
| - V4UpdateCallback callback = base::Bind(
|
| - &V4LocalDatabaseManager::UpdateRequestCompleted, base::Unretained(this));
|
| + V4UpdateCallback callback =
|
| + base::Bind(&V4LocalDatabaseManager::UpdateRequestCompleted,
|
| + weak_factory_.GetWeakPtr());
|
|
|
| v4_update_protocol_manager_ =
|
| V4UpdateProtocolManager::Create(request_context_getter, config, callback);
|
|
|