| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 282 |
| 283 void V4LocalDatabaseManager::DatabaseReadyForChecks( | 283 void V4LocalDatabaseManager::DatabaseReadyForChecks( |
| 284 std::unique_ptr<V4Database> v4_database) { | 284 std::unique_ptr<V4Database> v4_database) { |
| 285 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 285 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 286 | 286 |
| 287 // The following check is needed because it is possible that by the time the | 287 // The following check is needed because it is possible that by the time the |
| 288 // database is ready, StopOnIOThread has been called. | 288 // database is ready, StopOnIOThread has been called. |
| 289 if (enabled_) { | 289 if (enabled_) { |
| 290 v4_database_ = std::move(v4_database); | 290 v4_database_ = std::move(v4_database); |
| 291 | 291 |
| 292 v4_database_->RecordFileSizeHistograms(); |
| 293 |
| 292 // The consistency of the stores read from the disk needs to verified. Post | 294 // The consistency of the stores read from the disk needs to verified. Post |
| 293 // that task on the task runner. It calls |DatabaseReadyForUpdates| | 295 // that task on the task runner. It calls |DatabaseReadyForUpdates| |
| 294 // callback with the stores to reset, if any, and then we can schedule the | 296 // callback with the stores to reset, if any, and then we can schedule the |
| 295 // database updates. | 297 // database updates. |
| 296 v4_database_->VerifyChecksum( | 298 v4_database_->VerifyChecksum( |
| 297 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates, | 299 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates, |
| 298 weak_factory_.GetWeakPtr())); | 300 weak_factory_.GetWeakPtr())); |
| 299 | 301 |
| 300 ProcessQueuedChecks(); | 302 ProcessQueuedChecks(); |
| 301 } else { | 303 } else { |
| 302 // Schedule the deletion of v4_database off IO thread. | 304 // Schedule the deletion of v4_database off IO thread. |
| 303 V4Database::Destroy(std::move(v4_database)); | 305 V4Database::Destroy(std::move(v4_database)); |
| 304 } | 306 } |
| 305 } | 307 } |
| 306 | 308 |
| 307 void V4LocalDatabaseManager::DatabaseReadyForUpdates( | 309 void V4LocalDatabaseManager::DatabaseReadyForUpdates( |
| 308 const std::vector<ListIdentifier>& stores_to_reset) { | 310 const std::vector<ListIdentifier>& stores_to_reset) { |
| 309 if (enabled_) { | 311 if (enabled_) { |
| 310 v4_database_->ResetStores(stores_to_reset); | 312 v4_database_->ResetStores(stores_to_reset); |
| 311 | 313 |
| 312 // The database is ready to process updates. Schedule them now. | 314 // The database is ready to process updates. Schedule them now. |
| 313 v4_update_protocol_manager_->ScheduleNextUpdate( | 315 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 314 v4_database_->GetStoreStateMap()); | 316 v4_database_->GetStoreStateMap()); |
| 315 } | 317 } |
| 316 } | 318 } |
| 317 | 319 |
| 318 void V4LocalDatabaseManager::DatabaseUpdated() { | 320 void V4LocalDatabaseManager::DatabaseUpdated() { |
| 319 if (enabled_) { | 321 if (enabled_) { |
| 322 v4_database_->RecordFileSizeHistograms(); |
| 320 v4_update_protocol_manager_->ScheduleNextUpdate( | 323 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 321 v4_database_->GetStoreStateMap()); | 324 v4_database_->GetStoreStateMap()); |
| 322 } | 325 } |
| 323 } | 326 } |
| 324 | 327 |
| 325 bool V4LocalDatabaseManager::GetPrefixMatches( | 328 bool V4LocalDatabaseManager::GetPrefixMatches( |
| 326 const std::unique_ptr<PendingCheck>& check, | 329 const std::unique_ptr<PendingCheck>& check, |
| 327 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) { | 330 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) { |
| 328 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 331 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 329 | 332 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 539 } |
| 537 | 540 |
| 538 void V4LocalDatabaseManager::UpdateRequestCompleted( | 541 void V4LocalDatabaseManager::UpdateRequestCompleted( |
| 539 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 542 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
| 540 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 543 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 541 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 544 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
| 542 db_updated_callback_); | 545 db_updated_callback_); |
| 543 } | 546 } |
| 544 | 547 |
| 545 } // namespace safe_browsing | 548 } // namespace safe_browsing |
| OLD | NEW |