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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 ListInfo(kSyncNever, "", GetChromeUrlApiId(), SB_THREAT_TYPE_API_ABUSE), | 74 ListInfo(kSyncNever, "", GetChromeUrlApiId(), SB_THREAT_TYPE_API_ABUSE), |
75 }); | 75 }); |
76 } | 76 } |
77 | 77 |
78 // Returns the severity information about a given SafeBrowsing list. The lowest | 78 // Returns the severity information about a given SafeBrowsing list. The lowest |
79 // value is 0, which represents the most severe list. | 79 // value is 0, which represents the most severe list. |
80 ThreatSeverity GetThreatSeverity(const ListIdentifier& list_id) { | 80 ThreatSeverity GetThreatSeverity(const ListIdentifier& list_id) { |
81 switch (list_id.threat_type()) { | 81 switch (list_id.threat_type()) { |
82 case MALWARE_THREAT: | 82 case MALWARE_THREAT: |
83 case SOCIAL_ENGINEERING_PUBLIC: | 83 case SOCIAL_ENGINEERING_PUBLIC: |
| 84 case MALICIOUS_BINARY: |
84 return 0; | 85 return 0; |
85 case UNWANTED_SOFTWARE: | 86 case UNWANTED_SOFTWARE: |
86 return 1; | 87 return 1; |
87 case API_ABUSE: | 88 case API_ABUSE: |
88 return 2; | 89 return 2; |
89 default: | 90 default: |
90 NOTREACHED() << "Unexpected ThreatType encountered in GetThreatSeverity"; | 91 NOTREACHED() << "Unexpected ThreatType encountered: " |
| 92 << list_id.threat_type(); |
91 return kLeastSeverity; | 93 return kLeastSeverity; |
92 } | 94 } |
93 } | 95 } |
94 | 96 |
95 } // namespace | 97 } // namespace |
96 | 98 |
97 V4LocalDatabaseManager::PendingCheck::PendingCheck( | 99 V4LocalDatabaseManager::PendingCheck::PendingCheck( |
98 Client* client, | 100 Client* client, |
99 ClientCallbackType client_callback_type, | 101 ClientCallbackType client_callback_type, |
100 const StoresToCheck& stores_to_check, | 102 const StoresToCheck& stores_to_check, |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 const std::unique_ptr<PendingCheck>& check, | 430 const std::unique_ptr<PendingCheck>& check, |
429 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) { | 431 FullHashToStoreAndHashPrefixesMap* full_hash_to_store_and_hash_prefixes) { |
430 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 432 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
431 | 433 |
432 DCHECK(enabled_); | 434 DCHECK(enabled_); |
433 DCHECK(v4_database_); | 435 DCHECK(v4_database_); |
434 | 436 |
435 const base::TimeTicks before = TimeTicks::Now(); | 437 const base::TimeTicks before = TimeTicks::Now(); |
436 if (check->client_callback_type == ClientCallbackType::CHECK_BROWSE_URL || | 438 if (check->client_callback_type == ClientCallbackType::CHECK_BROWSE_URL || |
437 check->client_callback_type == ClientCallbackType::CHECK_DOWNLOAD_URLS || | 439 check->client_callback_type == ClientCallbackType::CHECK_DOWNLOAD_URLS || |
| 440 check->client_callback_type == ClientCallbackType::CHECK_RESOURCE_URL || |
438 check->client_callback_type == ClientCallbackType::CHECK_EXTENSION_IDS || | 441 check->client_callback_type == ClientCallbackType::CHECK_EXTENSION_IDS || |
439 check->client_callback_type == ClientCallbackType::CHECK_OTHER) { | 442 check->client_callback_type == ClientCallbackType::CHECK_OTHER) { |
440 DCHECK(!check->full_hashes.empty()); | 443 DCHECK(!check->full_hashes.empty()); |
441 | 444 |
442 full_hash_to_store_and_hash_prefixes->clear(); | 445 full_hash_to_store_and_hash_prefixes->clear(); |
443 for (const auto& full_hash : check->full_hashes) { | 446 for (const auto& full_hash : check->full_hashes) { |
444 StoreAndHashPrefixes matched_store_and_hash_prefixes; | 447 StoreAndHashPrefixes matched_store_and_hash_prefixes; |
445 v4_database_->GetStoresMatchingFullHash(full_hash, check->stores_to_check, | 448 v4_database_->GetStoresMatchingFullHash(full_hash, check->stores_to_check, |
446 &matched_store_and_hash_prefixes); | 449 &matched_store_and_hash_prefixes); |
447 if (!matched_store_and_hash_prefixes.empty()) { | 450 if (!matched_store_and_hash_prefixes.empty()) { |
448 (*full_hash_to_store_and_hash_prefixes)[full_hash] = | 451 (*full_hash_to_store_and_hash_prefixes)[full_hash] = |
449 matched_store_and_hash_prefixes; | 452 matched_store_and_hash_prefixes; |
450 } | 453 } |
451 } | 454 } |
452 } else { | 455 } else { |
453 NOTREACHED() << "Unexpected client_callback_type encountered"; | 456 NOTREACHED() << "Unexpected client_callback_type encountered."; |
454 } | 457 } |
455 | 458 |
456 // TODO(vakh): Only log SafeBrowsing.V4GetPrefixMatches.Time once PVer3 code | 459 // TODO(vakh): Only log SafeBrowsing.V4GetPrefixMatches.Time once PVer3 code |
457 // is removed. | 460 // is removed. |
458 // NOTE(vakh): This doesn't distinguish which stores it's searching through. | 461 // NOTE(vakh): This doesn't distinguish which stores it's searching through. |
459 // However, the vast majority of the entries in this histogram will be from | 462 // However, the vast majority of the entries in this histogram will be from |
460 // searching the three CHECK_BROWSE_URL stores. | 463 // searching the three CHECK_BROWSE_URL stores. |
461 base::TimeDelta diff = TimeTicks::Now() - before; | 464 base::TimeDelta diff = TimeTicks::Now() - before; |
462 UMA_HISTOGRAM_TIMES("SB2.FilterCheck", diff); | 465 UMA_HISTOGRAM_TIMES("SB2.FilterCheck", diff); |
463 UMA_HISTOGRAM_CUSTOM_TIMES("SafeBrowsing.V4GetPrefixMatches.Time", diff, | 466 UMA_HISTOGRAM_CUSTOM_TIMES("SafeBrowsing.V4GetPrefixMatches.Time", diff, |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 } | 677 } |
675 | 678 |
676 void V4LocalDatabaseManager::UpdateRequestCompleted( | 679 void V4LocalDatabaseManager::UpdateRequestCompleted( |
677 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 680 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
678 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 681 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
679 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 682 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
680 db_updated_callback_); | 683 db_updated_callback_); |
681 } | 684 } |
682 | 685 |
683 } // namespace safe_browsing | 686 } // namespace safe_browsing |
OLD | NEW |