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

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

Issue 2447443002: Log the size of each of the stores and complete DB on launch and after each (Closed)
Patch Set: shess@'s review Created 4 years, 1 month 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 // 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 void V4LocalDatabaseManager::DatabaseReadyForChecks( 290 void V4LocalDatabaseManager::DatabaseReadyForChecks(
291 std::unique_ptr<V4Database> v4_database) { 291 std::unique_ptr<V4Database> v4_database) {
292 DCHECK_CURRENTLY_ON(BrowserThread::IO); 292 DCHECK_CURRENTLY_ON(BrowserThread::IO);
293 293
294 // The following check is needed because it is possible that by the time the 294 // The following check is needed because it is possible that by the time the
295 // database is ready, StopOnIOThread has been called. 295 // database is ready, StopOnIOThread has been called.
296 if (enabled_) { 296 if (enabled_) {
297 v4_database_ = std::move(v4_database); 297 v4_database_ = std::move(v4_database);
298 298
299 v4_database_->RecordFileSizeHistograms();
300
299 // The consistency of the stores read from the disk needs to verified. Post 301 // The consistency of the stores read from the disk needs to verified. Post
300 // that task on the task runner. It calls |DatabaseReadyForUpdates| 302 // that task on the task runner. It calls |DatabaseReadyForUpdates|
301 // callback with the stores to reset, if any, and then we can schedule the 303 // callback with the stores to reset, if any, and then we can schedule the
302 // database updates. 304 // database updates.
303 v4_database_->VerifyChecksum( 305 v4_database_->VerifyChecksum(
304 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates, 306 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates,
305 weak_factory_.GetWeakPtr())); 307 weak_factory_.GetWeakPtr()));
306 308
307 ProcessQueuedChecks(); 309 ProcessQueuedChecks();
308 } else { 310 } else {
309 // Schedule the deletion of v4_database off IO thread. 311 // Schedule the deletion of v4_database off IO thread.
310 V4Database::Destroy(std::move(v4_database)); 312 V4Database::Destroy(std::move(v4_database));
311 } 313 }
312 } 314 }
313 315
314 void V4LocalDatabaseManager::DatabaseReadyForUpdates( 316 void V4LocalDatabaseManager::DatabaseReadyForUpdates(
315 const std::vector<ListIdentifier>& stores_to_reset) { 317 const std::vector<ListIdentifier>& stores_to_reset) {
316 if (enabled_) { 318 if (enabled_) {
317 v4_database_->ResetStores(stores_to_reset); 319 v4_database_->ResetStores(stores_to_reset);
318 320
319 // The database is ready to process updates. Schedule them now. 321 // The database is ready to process updates. Schedule them now.
320 v4_update_protocol_manager_->ScheduleNextUpdate( 322 v4_update_protocol_manager_->ScheduleNextUpdate(
321 v4_database_->GetStoreStateMap()); 323 v4_database_->GetStoreStateMap());
322 } 324 }
323 } 325 }
324 326
325 void V4LocalDatabaseManager::DatabaseUpdated() { 327 void V4LocalDatabaseManager::DatabaseUpdated() {
326 if (enabled_) { 328 if (enabled_) {
329 v4_database_->RecordFileSizeHistograms();
327 v4_update_protocol_manager_->ScheduleNextUpdate( 330 v4_update_protocol_manager_->ScheduleNextUpdate(
328 v4_database_->GetStoreStateMap()); 331 v4_database_->GetStoreStateMap());
329 } 332 }
330 } 333 }
331 334
332 bool V4LocalDatabaseManager::GetPrefixMatches( 335 bool V4LocalDatabaseManager::GetPrefixMatches(
333 const std::unique_ptr<PendingCheck>& check, 336 const std::unique_ptr<PendingCheck>& check,
334 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) { 337 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) {
335 DCHECK_CURRENTLY_ON(BrowserThread::IO); 338 DCHECK_CURRENTLY_ON(BrowserThread::IO);
336 339
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 511 }
509 512
510 void V4LocalDatabaseManager::UpdateRequestCompleted( 513 void V4LocalDatabaseManager::UpdateRequestCompleted(
511 std::unique_ptr<ParsedServerResponse> parsed_server_response) { 514 std::unique_ptr<ParsedServerResponse> parsed_server_response) {
512 DCHECK_CURRENTLY_ON(BrowserThread::IO); 515 DCHECK_CURRENTLY_ON(BrowserThread::IO);
513 v4_database_->ApplyUpdate(std::move(parsed_server_response), 516 v4_database_->ApplyUpdate(std::move(parsed_server_response),
514 db_updated_callback_); 517 db_updated_callback_);
515 } 518 }
516 519
517 } // namespace safe_browsing 520 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698