| OLD | NEW |
| 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 // This file should not be build on Android but is currently getting built. | 5 // This file should not be build on Android but is currently getting built. |
| 6 // TODO(vakh): Fix that: http://crbug.com/621647 | 6 // TODO(vakh): Fix that: http://crbug.com/621647 |
| 7 | 7 |
| 8 #include "components/safe_browsing_db/v4_local_database_manager.h" | 8 #include "components/safe_browsing_db/v4_local_database_manager.h" |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 void V4LocalDatabaseManager::DatabaseReadyForChecks( | 292 void V4LocalDatabaseManager::DatabaseReadyForChecks( |
| 293 std::unique_ptr<V4Database> v4_database) { | 293 std::unique_ptr<V4Database> v4_database) { |
| 294 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 294 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 295 | 295 |
| 296 // The following check is needed because it is possible that by the time the | 296 // The following check is needed because it is possible that by the time the |
| 297 // database is ready, StopOnIOThread has been called. | 297 // database is ready, StopOnIOThread has been called. |
| 298 if (enabled_) { | 298 if (enabled_) { |
| 299 v4_database_ = std::move(v4_database); | 299 v4_database_ = std::move(v4_database); |
| 300 | 300 |
| 301 v4_database_->RecordFileSizeHistograms(); |
| 302 |
| 301 // The consistency of the stores read from the disk needs to verified. Post | 303 // The consistency of the stores read from the disk needs to verified. Post |
| 302 // that task on the task runner. It calls |DatabaseReadyForUpdates| | 304 // that task on the task runner. It calls |DatabaseReadyForUpdates| |
| 303 // callback with the stores to reset, if any, and then we can schedule the | 305 // callback with the stores to reset, if any, and then we can schedule the |
| 304 // database updates. | 306 // database updates. |
| 305 v4_database_->VerifyChecksum( | 307 v4_database_->VerifyChecksum( |
| 306 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates, | 308 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates, |
| 307 weak_factory_.GetWeakPtr())); | 309 weak_factory_.GetWeakPtr())); |
| 308 | 310 |
| 309 ProcessQueuedChecks(); | 311 ProcessQueuedChecks(); |
| 310 } else { | 312 } else { |
| 311 // Schedule the deletion of v4_database off IO thread. | 313 // Schedule the deletion of v4_database off IO thread. |
| 312 V4Database::Destroy(std::move(v4_database)); | 314 V4Database::Destroy(std::move(v4_database)); |
| 313 } | 315 } |
| 314 } | 316 } |
| 315 | 317 |
| 316 void V4LocalDatabaseManager::DatabaseReadyForUpdates( | 318 void V4LocalDatabaseManager::DatabaseReadyForUpdates( |
| 317 const std::vector<ListIdentifier>& stores_to_reset) { | 319 const std::vector<ListIdentifier>& stores_to_reset) { |
| 318 if (enabled_) { | 320 if (enabled_) { |
| 319 v4_database_->ResetStores(stores_to_reset); | 321 v4_database_->ResetStores(stores_to_reset); |
| 320 | 322 |
| 321 // The database is ready to process updates. Schedule them now. | 323 // The database is ready to process updates. Schedule them now. |
| 322 v4_update_protocol_manager_->ScheduleNextUpdate( | 324 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 323 v4_database_->GetStoreStateMap()); | 325 v4_database_->GetStoreStateMap()); |
| 324 } | 326 } |
| 325 } | 327 } |
| 326 | 328 |
| 327 void V4LocalDatabaseManager::DatabaseUpdated() { | 329 void V4LocalDatabaseManager::DatabaseUpdated() { |
| 328 if (enabled_) { | 330 if (enabled_) { |
| 331 v4_database_->RecordFileSizeHistograms(); |
| 329 v4_update_protocol_manager_->ScheduleNextUpdate( | 332 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 330 v4_database_->GetStoreStateMap()); | 333 v4_database_->GetStoreStateMap()); |
| 331 } | 334 } |
| 332 } | 335 } |
| 333 | 336 |
| 334 bool V4LocalDatabaseManager::GetPrefixMatches( | 337 bool V4LocalDatabaseManager::GetPrefixMatches( |
| 335 const std::unique_ptr<PendingCheck>& check, | 338 const std::unique_ptr<PendingCheck>& check, |
| 336 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) { | 339 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) { |
| 337 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 340 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 338 | 341 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } | 522 } |
| 520 | 523 |
| 521 void V4LocalDatabaseManager::UpdateRequestCompleted( | 524 void V4LocalDatabaseManager::UpdateRequestCompleted( |
| 522 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 525 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
| 523 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 526 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 524 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 527 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
| 525 db_updated_callback_); | 528 db_updated_callback_); |
| 526 } | 529 } |
| 527 | 530 |
| 528 } // namespace safe_browsing | 531 } // namespace safe_browsing |
| OLD | NEW |