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

Side by Side Diff: chrome/browser/safe_browsing/local_database_manager.cc

Issue 1579183003: Only call UrlToFullHashes once from LocalSafeBrowsingDatabaseManager::CheckBrowseUrl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix param name Created 4 years, 11 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/safe_browsing/local_database_manager.h" 5 #include "chrome/browser/safe_browsing/local_database_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 queued_checks_.push_back(queued_check); 473 queued_checks_.push_back(queued_check);
474 return false; 474 return false;
475 } 475 }
476 476
477 // Cache hits should, in general, be the same for both (ignoring potential 477 // Cache hits should, in general, be the same for both (ignoring potential
478 // cache evictions in the second call for entries that were just about to be 478 // cache evictions in the second call for entries that were just about to be
479 // evicted in the first call). 479 // evicted in the first call).
480 // TODO(gab): Refactor SafeBrowsingDatabase to avoid depending on this here. 480 // TODO(gab): Refactor SafeBrowsingDatabase to avoid depending on this here.
481 std::vector<SBFullHashResult> cache_hits; 481 std::vector<SBFullHashResult> cache_hits;
482 482
483 std::vector<SBFullHash> full_hashes;
484 UrlToFullHashes(url, false, &full_hashes);
485
483 std::vector<SBPrefix> browse_prefix_hits; 486 std::vector<SBPrefix> browse_prefix_hits;
484 bool browse_prefix_match = database_->ContainsBrowseUrl( 487 bool browse_prefix_match = database_->ContainsBrowseHashes(
485 url, &browse_prefix_hits, &cache_hits); 488 full_hashes, &browse_prefix_hits, &cache_hits);
486 489
487 std::vector<SBPrefix> unwanted_prefix_hits; 490 std::vector<SBPrefix> unwanted_prefix_hits;
488 std::vector<SBFullHashResult> unused_cache_hits; 491 std::vector<SBFullHashResult> unused_cache_hits;
489 bool unwanted_prefix_match = database_->ContainsUnwantedSoftwareUrl( 492 bool unwanted_prefix_match = database_->ContainsUnwantedSoftwareHashes(
490 url, &unwanted_prefix_hits, &unused_cache_hits); 493 full_hashes, &unwanted_prefix_hits, &unused_cache_hits);
491 494
492 // Merge the two pre-sorted prefix hits lists. 495 // Merge the two pre-sorted prefix hits lists.
493 // TODO(gab): Refactor SafeBrowsingDatabase for it to return this merged list 496 // TODO(gab): Refactor SafeBrowsingDatabase for it to return this merged list
494 // by default rather than building it here. 497 // by default rather than building it here.
495 std::vector<SBPrefix> prefix_hits(browse_prefix_hits.size() + 498 std::vector<SBPrefix> prefix_hits(browse_prefix_hits.size() +
496 unwanted_prefix_hits.size()); 499 unwanted_prefix_hits.size());
497 std::merge(browse_prefix_hits.begin(), 500 std::merge(browse_prefix_hits.begin(),
498 browse_prefix_hits.end(), 501 browse_prefix_hits.end(),
499 unwanted_prefix_hits.begin(), 502 unwanted_prefix_hits.begin(),
500 unwanted_prefix_hits.end(), 503 unwanted_prefix_hits.end(),
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, 1193 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback,
1191 check->weak_ptr_factory_->GetWeakPtr(), check), 1194 check->weak_ptr_factory_->GetWeakPtr(), check),
1192 check_timeout_); 1195 check_timeout_);
1193 } 1196 }
1194 1197
1195 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { 1198 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const {
1196 return enable_download_protection_; 1199 return enable_download_protection_;
1197 } 1200 }
1198 1201
1199 } // namespace safe_browsing 1202 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698