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

Unified Diff: components/safe_browsing_db/v4_database.cc

Issue 2814733002: Add the SocEng as a type for checking in CheckUrlForSubresourceFilter. (Closed)
Patch Set: . Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/safe_browsing_db/v4_database.h ('k') | components/safe_browsing_db/v4_database_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_database.cc
diff --git a/components/safe_browsing_db/v4_database.cc b/components/safe_browsing_db/v4_database.cc
index c1c7b3eedcde90a0736dd7ed77c61e67c7ea76ed..9164951b2fb80300e2fbf0a88078ea2783095d5c 100644
--- a/components/safe_browsing_db/v4_database.cc
+++ b/components/safe_browsing_db/v4_database.cc
@@ -204,17 +204,22 @@ std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() {
return store_state_map;
}
-bool V4Database::AreStoresAvailable(
+bool V4Database::AreAnyStoresAvailable(
const StoresToCheck& stores_to_check) const {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
for (const ListIdentifier& identifier : stores_to_check) {
- const auto& store_pair = store_map_->find(identifier);
- if (store_pair == store_map_->end()) {
- return false; // Store not in our list
- }
- if (!store_pair->second->HasValidData()) {
- return false; // Store never properly populated.
- }
+ if (IsStoreAvailable(identifier))
+ return true;
+ }
+ return false;
+}
+
+bool V4Database::AreAllStoresAvailable(
+ const StoresToCheck& stores_to_check) const {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ for (const ListIdentifier& identifier : stores_to_check) {
+ if (!IsStoreAvailable(identifier))
+ return false;
}
return true;
}
@@ -226,6 +231,8 @@ void V4Database::GetStoresMatchingFullHash(
DCHECK_CURRENTLY_ON(BrowserThread::IO);
matched_store_and_hash_prefixes->clear();
for (const ListIdentifier& identifier : stores_to_check) {
+ if (!IsStoreAvailable(identifier))
+ continue;
const auto& store_pair = store_map_->find(identifier);
DCHECK(store_pair != store_map_->end());
const std::unique_ptr<V4Store>& store = store_pair->second;
@@ -271,6 +278,19 @@ void V4Database::VerifyChecksumOnTaskRunner(
FROM_HERE, base::Bind(db_ready_for_updates_callback, stores_to_reset));
}
+bool V4Database::IsStoreAvailable(const ListIdentifier& identifier) const {
+ const auto& store_pair = store_map_->find(identifier);
+ if (store_pair == store_map_->end()) {
+ // Store not in our list
+ return false;
+ }
+ if (!store_pair->second->HasValidData()) {
+ // Store never properly populated
+ return false;
+ }
+ return true;
+}
+
void V4Database::RecordFileSizeHistograms() {
int64_t db_size = 0;
for (const auto& store_map_iter : *store_map_) {
« no previous file with comments | « components/safe_browsing_db/v4_database.h ('k') | components/safe_browsing_db/v4_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698