| 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 e640abe9d62121bd5014e2fd59ca4ca61eaa795d..994ec8e4441b6a6d5d095de856522639d93e9474 100644
|
| --- a/components/safe_browsing_db/v4_local_database_manager.cc
|
| +++ b/components/safe_browsing_db/v4_local_database_manager.cc
|
| @@ -79,7 +79,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());
|
|
|
| @@ -245,7 +248,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();
|
| @@ -295,7 +298,7 @@ void V4LocalDatabaseManager::DatabaseReadyForChecks(
|
| // database updates.
|
| v4_database_->VerifyChecksum(
|
| base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates,
|
| - base::Unretained(this)));
|
| + weak_factory_.GetWeakPtr()));
|
|
|
| ProcessQueuedChecks();
|
| } else {
|
| @@ -430,7 +433,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() {
|
| @@ -478,16 +481,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);
|
|
|