Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/safe_browsing_database.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 bool enable_download_whitelist, | 287 bool enable_download_whitelist, |
| 288 bool enable_extension_blacklist, | 288 bool enable_extension_blacklist, |
| 289 bool enable_ip_blacklist, | 289 bool enable_ip_blacklist, |
| 290 bool enable_unwanted_software_list, | 290 bool enable_unwanted_software_list, |
| 291 bool enable_module_whitelist) override { | 291 bool enable_module_whitelist) override { |
| 292 return new SafeBrowsingDatabaseNew( | 292 return new SafeBrowsingDatabaseNew( |
| 293 db_task_runner, CreateStore(true, db_task_runner), // browse_store | 293 db_task_runner, CreateStore(true, db_task_runner), // browse_store |
| 294 CreateStore(enable_download_protection, db_task_runner), | 294 CreateStore(enable_download_protection, db_task_runner), |
| 295 CreateStore(enable_client_side_whitelist, db_task_runner), | 295 CreateStore(enable_client_side_whitelist, db_task_runner), |
| 296 CreateStore(enable_download_whitelist, db_task_runner), | 296 CreateStore(enable_download_whitelist, db_task_runner), |
| 297 CreateStore(true, db_task_runner), // inclusion_whitelist_store | |
| 298 CreateStore(enable_extension_blacklist, db_task_runner), | 297 CreateStore(enable_extension_blacklist, db_task_runner), |
| 299 CreateStore(enable_ip_blacklist, db_task_runner), | 298 CreateStore(enable_ip_blacklist, db_task_runner), |
| 300 CreateStore(enable_unwanted_software_list, db_task_runner), | 299 CreateStore(enable_unwanted_software_list, db_task_runner), |
| 301 CreateStore(enable_module_whitelist, db_task_runner), | 300 CreateStore(enable_module_whitelist, db_task_runner), |
| 302 CreateStore(true, db_task_runner)); // resource_blacklist_store | 301 CreateStore(true, db_task_runner)); // resource_blacklist_store |
| 303 } | 302 } |
| 304 | 303 |
| 305 SafeBrowsingDatabaseFactoryImpl() {} | 304 SafeBrowsingDatabaseFactoryImpl() {} |
| 306 | 305 |
| 307 private: | 306 private: |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 431 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); |
| 433 | 432 |
| 434 if (list_id == PHISH || list_id == MALWARE) { | 433 if (list_id == PHISH || list_id == MALWARE) { |
| 435 return browse_store_.get(); | 434 return browse_store_.get(); |
| 436 } else if (list_id == BINURL) { | 435 } else if (list_id == BINURL) { |
| 437 return download_store_.get(); | 436 return download_store_.get(); |
| 438 } else if (list_id == CSDWHITELIST) { | 437 } else if (list_id == CSDWHITELIST) { |
| 439 return csd_whitelist_store_.get(); | 438 return csd_whitelist_store_.get(); |
| 440 } else if (list_id == DOWNLOADWHITELIST) { | 439 } else if (list_id == DOWNLOADWHITELIST) { |
| 441 return download_whitelist_store_.get(); | 440 return download_whitelist_store_.get(); |
| 442 } else if (list_id == INCLUSIONWHITELIST) { | |
| 443 return inclusion_whitelist_store_.get(); | |
| 444 } else if (list_id == EXTENSIONBLACKLIST) { | 441 } else if (list_id == EXTENSIONBLACKLIST) { |
| 445 return extension_blacklist_store_.get(); | 442 return extension_blacklist_store_.get(); |
| 446 } else if (list_id == IPBLACKLIST) { | 443 } else if (list_id == IPBLACKLIST) { |
| 447 return ip_blacklist_store_.get(); | 444 return ip_blacklist_store_.get(); |
| 448 } else if (list_id == UNWANTEDURL) { | 445 } else if (list_id == UNWANTEDURL) { |
| 449 return unwanted_software_store_.get(); | 446 return unwanted_software_store_.get(); |
| 450 } else if (list_id == MODULEWHITELIST) { | 447 } else if (list_id == MODULEWHITELIST) { |
| 451 return module_whitelist_store_.get(); | 448 return module_whitelist_store_.get(); |
| 452 } else if (list_id == RESOURCEBLACKLIST) { | 449 } else if (list_id == RESOURCEBLACKLIST) { |
| 453 return resource_blacklist_store_.get(); | 450 return resource_blacklist_store_.get(); |
| 454 } | 451 } |
| 455 return NULL; | 452 return NULL; |
| 456 } | 453 } |
| 457 | 454 |
| 458 // static | 455 // static |
| 459 void SafeBrowsingDatabase::RecordFailure(FailureType failure_type) { | 456 void SafeBrowsingDatabase::RecordFailure(FailureType failure_type) { |
| 460 UMA_HISTOGRAM_ENUMERATION("SB2.DatabaseFailure", failure_type, | 457 UMA_HISTOGRAM_ENUMERATION("SB2.DatabaseFailure", failure_type, |
| 461 FAILURE_DATABASE_MAX); | 458 FAILURE_DATABASE_MAX); |
| 462 } | 459 } |
| 463 | 460 |
| 464 class SafeBrowsingDatabaseNew::ThreadSafeStateManager::ReadTransaction { | 461 class SafeBrowsingDatabaseNew::ThreadSafeStateManager::ReadTransaction { |
| 465 public: | 462 public: |
| 466 const SBWhitelist* GetSBWhitelist(SBWhitelistId id) { | 463 const SBWhitelist* GetSBWhitelist(SBWhitelistId id) { |
| 467 switch (id) { | 464 switch (id) { |
| 468 case SBWhitelistId::CSD: | 465 case SBWhitelistId::CSD: |
| 469 return &outer_->csd_whitelist_; | 466 return &outer_->csd_whitelist_; |
| 470 case SBWhitelistId::DOWNLOAD: | 467 case SBWhitelistId::DOWNLOAD: |
| 471 return &outer_->download_whitelist_; | 468 return &outer_->download_whitelist_; |
| 472 case SBWhitelistId::INCLUSION: | |
| 473 return &outer_->inclusion_whitelist_; | |
| 474 case SBWhitelistId::MODULE: | 469 case SBWhitelistId::MODULE: |
| 475 return &outer_->module_whitelist_; | 470 return &outer_->module_whitelist_; |
| 471 case SBWhitelistId::obsolete_INCLUSION: | |
| 472 // Do nothing. | |
| 473 break; | |
| 476 } | 474 } |
| 477 NOTREACHED(); | 475 NOTREACHED(); |
| 478 return nullptr; | 476 return nullptr; |
| 479 } | 477 } |
| 480 | 478 |
| 481 const IPBlacklist* ip_blacklist() { return &outer_->ip_blacklist_; } | 479 const IPBlacklist* ip_blacklist() { return &outer_->ip_blacklist_; } |
| 482 | 480 |
| 483 const PrefixSet* GetPrefixSet(PrefixSetId id) { | 481 const PrefixSet* GetPrefixSet(PrefixSetId id) { |
| 484 switch (id) { | 482 switch (id) { |
| 485 case PrefixSetId::BROWSE: | 483 case PrefixSetId::BROWSE: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 DCHECK(outer_); | 572 DCHECK(outer_); |
| 575 DCHECK(outer_->db_task_runner_->RunsTasksOnCurrentThread()); | 573 DCHECK(outer_->db_task_runner_->RunsTasksOnCurrentThread()); |
| 576 } | 574 } |
| 577 | 575 |
| 578 SBWhitelist* SBWhitelistForId(SBWhitelistId id) { | 576 SBWhitelist* SBWhitelistForId(SBWhitelistId id) { |
| 579 switch (id) { | 577 switch (id) { |
| 580 case SBWhitelistId::CSD: | 578 case SBWhitelistId::CSD: |
| 581 return &outer_->csd_whitelist_; | 579 return &outer_->csd_whitelist_; |
| 582 case SBWhitelistId::DOWNLOAD: | 580 case SBWhitelistId::DOWNLOAD: |
| 583 return &outer_->download_whitelist_; | 581 return &outer_->download_whitelist_; |
| 584 case SBWhitelistId::INCLUSION: | |
| 585 return &outer_->inclusion_whitelist_; | |
| 586 case SBWhitelistId::MODULE: | 582 case SBWhitelistId::MODULE: |
| 587 return &outer_->module_whitelist_; | 583 return &outer_->module_whitelist_; |
| 584 case SBWhitelistId::obsolete_INCLUSION: | |
| 585 // Do nothing. | |
| 586 break; | |
| 588 } | 587 } |
| 589 NOTREACHED(); | 588 NOTREACHED(); |
| 590 return nullptr; | 589 return nullptr; |
| 591 } | 590 } |
| 592 | 591 |
| 593 ThreadSafeStateManager* outer_; | 592 ThreadSafeStateManager* outer_; |
| 594 base::AutoLock transaction_lock_; | 593 base::AutoLock transaction_lock_; |
| 595 | 594 |
| 596 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); | 595 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); |
| 597 }; | 596 }; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 628 SafeBrowsingDatabaseNew::ThreadSafeStateManager::BeginWriteTransaction() { | 627 SafeBrowsingDatabaseNew::ThreadSafeStateManager::BeginWriteTransaction() { |
| 629 return base::WrapUnique(new WriteTransaction(this)); | 628 return base::WrapUnique(new WriteTransaction(this)); |
| 630 } | 629 } |
| 631 | 630 |
| 632 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew( | 631 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew( |
| 633 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, | 632 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
| 634 SafeBrowsingStore* browse_store, | 633 SafeBrowsingStore* browse_store, |
| 635 SafeBrowsingStore* download_store, | 634 SafeBrowsingStore* download_store, |
| 636 SafeBrowsingStore* csd_whitelist_store, | 635 SafeBrowsingStore* csd_whitelist_store, |
| 637 SafeBrowsingStore* download_whitelist_store, | 636 SafeBrowsingStore* download_whitelist_store, |
| 638 SafeBrowsingStore* inclusion_whitelist_store, | |
| 639 SafeBrowsingStore* extension_blacklist_store, | 637 SafeBrowsingStore* extension_blacklist_store, |
| 640 SafeBrowsingStore* ip_blacklist_store, | 638 SafeBrowsingStore* ip_blacklist_store, |
| 641 SafeBrowsingStore* unwanted_software_store, | 639 SafeBrowsingStore* unwanted_software_store, |
| 642 SafeBrowsingStore* module_whitelist_store, | 640 SafeBrowsingStore* module_whitelist_store, |
| 643 SafeBrowsingStore* resource_blacklist_store) | 641 SafeBrowsingStore* resource_blacklist_store) |
| 644 : db_task_runner_(db_task_runner), | 642 : db_task_runner_(db_task_runner), |
| 645 state_manager_(db_task_runner_), | 643 state_manager_(db_task_runner_), |
| 646 db_state_manager_(db_task_runner_), | 644 db_state_manager_(db_task_runner_), |
| 647 browse_store_(browse_store), | 645 browse_store_(browse_store), |
| 648 download_store_(download_store), | 646 download_store_(download_store), |
| 649 csd_whitelist_store_(csd_whitelist_store), | 647 csd_whitelist_store_(csd_whitelist_store), |
| 650 download_whitelist_store_(download_whitelist_store), | 648 download_whitelist_store_(download_whitelist_store), |
| 651 inclusion_whitelist_store_(inclusion_whitelist_store), | |
| 652 extension_blacklist_store_(extension_blacklist_store), | 649 extension_blacklist_store_(extension_blacklist_store), |
| 653 ip_blacklist_store_(ip_blacklist_store), | 650 ip_blacklist_store_(ip_blacklist_store), |
| 654 unwanted_software_store_(unwanted_software_store), | 651 unwanted_software_store_(unwanted_software_store), |
| 655 module_whitelist_store_(module_whitelist_store), | 652 module_whitelist_store_(module_whitelist_store), |
| 656 resource_blacklist_store_(resource_blacklist_store), | 653 resource_blacklist_store_(resource_blacklist_store), |
| 657 reset_factory_(this) { | 654 reset_factory_(this) { |
| 658 DCHECK(browse_store_.get()); | 655 DCHECK(browse_store_.get()); |
| 659 } | 656 } |
| 660 | 657 |
| 661 SafeBrowsingDatabaseNew::~SafeBrowsingDatabaseNew() { | 658 SafeBrowsingDatabaseNew::~SafeBrowsingDatabaseNew() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 if (unwanted_software_store_.get()) { | 700 if (unwanted_software_store_.get()) { |
| 704 LoadPrefixSet( | 701 LoadPrefixSet( |
| 705 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()), | 702 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()), |
| 706 txn.get(), PrefixSetId::UNWANTED_SOFTWARE, | 703 txn.get(), PrefixSetId::UNWANTED_SOFTWARE, |
| 707 FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_READ); | 704 FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_READ); |
| 708 } | 705 } |
| 709 | 706 |
| 710 // Delete any files of the side-effect free sidelist that may be around | 707 // Delete any files of the side-effect free sidelist that may be around |
| 711 // from when it was previously enabled. | 708 // from when it was previously enabled. |
| 712 // | 709 // |
| 713 // TODO(davidben): Remove this after April 15, 2016. | 710 // TODO(davidben): Remove this after April 15, 2016. |
|
gab
2016/05/16 13:27:58
Remove this while you're here?
Joe Mason
2016/05/16 14:18:52
Prefer to do this in a followup since it's not log
gab
2016/05/16 20:43:52
As you wish.
| |
| 714 SafeBrowsingStoreFile::DeleteStore( | 711 SafeBrowsingStoreFile::DeleteStore( |
| 715 SideEffectFreeWhitelistDBFilename(db_state_manager_.filename_base())); | 712 SideEffectFreeWhitelistDBFilename(db_state_manager_.filename_base())); |
| 716 base::DeleteFile(PrefixSetForFilename(SideEffectFreeWhitelistDBFilename( | 713 base::DeleteFile(PrefixSetForFilename(SideEffectFreeWhitelistDBFilename( |
| 717 db_state_manager_.filename_base())), | 714 db_state_manager_.filename_base())), |
| 718 false); | 715 false); |
| 716 | |
| 717 // Delete any files of the off-domain inclusion whitelist that may be around | |
| 718 // from when it was previously enabled. | |
| 719 // | |
| 720 // TODO(joenotcharles): Remove this after May 11, 2017. | |
| 721 SafeBrowsingStoreFile::DeleteStore( | |
| 722 InclusionWhitelistDBFilename(db_state_manager_.filename_base())); | |
| 723 base::DeleteFile(PrefixSetForFilename(InclusionWhitelistDBFilename( | |
| 724 db_state_manager_.filename_base())), | |
| 725 false); | |
| 719 } | 726 } |
| 720 // Note: End the transaction early because LoadWhiteList() and | 727 // Note: End the transaction early because LoadWhiteList() and |
| 721 // WhitelistEverything() manage their own transactions. | 728 // WhitelistEverything() manage their own transactions. |
| 722 | 729 |
| 723 if (download_store_.get()) { | 730 if (download_store_.get()) { |
| 724 download_store_->Init( | 731 download_store_->Init( |
| 725 DownloadDBFilename(db_state_manager_.filename_base()), | 732 DownloadDBFilename(db_state_manager_.filename_base()), |
| 726 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, | 733 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, |
| 727 base::Unretained(this))); | 734 base::Unretained(this))); |
| 728 } | 735 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 756 LoadWhitelist(full_hashes, SBWhitelistId::DOWNLOAD); | 763 LoadWhitelist(full_hashes, SBWhitelistId::DOWNLOAD); |
| 757 } else { | 764 } else { |
| 758 state_manager_.BeginWriteTransaction()->WhitelistEverything( | 765 state_manager_.BeginWriteTransaction()->WhitelistEverything( |
| 759 SBWhitelistId::DOWNLOAD); | 766 SBWhitelistId::DOWNLOAD); |
| 760 } | 767 } |
| 761 } else { | 768 } else { |
| 762 state_manager_.BeginWriteTransaction()->WhitelistEverything( | 769 state_manager_.BeginWriteTransaction()->WhitelistEverything( |
| 763 SBWhitelistId::DOWNLOAD); // Just to be safe. | 770 SBWhitelistId::DOWNLOAD); // Just to be safe. |
| 764 } | 771 } |
| 765 | 772 |
| 766 if (inclusion_whitelist_store_.get()) { | |
| 767 inclusion_whitelist_store_->Init( | |
| 768 InclusionWhitelistDBFilename(db_state_manager_.filename_base()), | |
| 769 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, | |
| 770 base::Unretained(this))); | |
| 771 | |
| 772 std::vector<SBAddFullHash> full_hashes; | |
| 773 if (inclusion_whitelist_store_->GetAddFullHashes(&full_hashes)) { | |
| 774 LoadWhitelist(full_hashes, SBWhitelistId::INCLUSION); | |
| 775 } else { | |
| 776 state_manager_.BeginWriteTransaction()->WhitelistEverything( | |
| 777 SBWhitelistId::INCLUSION); | |
| 778 } | |
| 779 } else { | |
| 780 state_manager_.BeginWriteTransaction()->WhitelistEverything( | |
| 781 SBWhitelistId::INCLUSION); // Just to be safe. | |
| 782 } | |
| 783 | |
| 784 if (extension_blacklist_store_.get()) { | 773 if (extension_blacklist_store_.get()) { |
| 785 extension_blacklist_store_->Init( | 774 extension_blacklist_store_->Init( |
| 786 ExtensionBlacklistDBFilename(db_state_manager_.filename_base()), | 775 ExtensionBlacklistDBFilename(db_state_manager_.filename_base()), |
| 787 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, | 776 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, |
| 788 base::Unretained(this))); | 777 base::Unretained(this))); |
| 789 } | 778 } |
| 790 | 779 |
| 791 if (ip_blacklist_store_.get()) { | 780 if (ip_blacklist_store_.get()) { |
| 792 ip_blacklist_store_->Init( | 781 ip_blacklist_store_->Init( |
| 793 IpBlacklistDBFilename(db_state_manager_.filename_base()), | 782 IpBlacklistDBFilename(db_state_manager_.filename_base()), |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 UrlToFullHashes(url, true, &full_hashes); | 943 UrlToFullHashes(url, true, &full_hashes); |
| 955 return ContainsWhitelistedHashes(SBWhitelistId::CSD, full_hashes); | 944 return ContainsWhitelistedHashes(SBWhitelistId::CSD, full_hashes); |
| 956 } | 945 } |
| 957 | 946 |
| 958 bool SafeBrowsingDatabaseNew::ContainsDownloadWhitelistedUrl(const GURL& url) { | 947 bool SafeBrowsingDatabaseNew::ContainsDownloadWhitelistedUrl(const GURL& url) { |
| 959 std::vector<SBFullHash> full_hashes; | 948 std::vector<SBFullHash> full_hashes; |
| 960 UrlToFullHashes(url, true, &full_hashes); | 949 UrlToFullHashes(url, true, &full_hashes); |
| 961 return ContainsWhitelistedHashes(SBWhitelistId::DOWNLOAD, full_hashes); | 950 return ContainsWhitelistedHashes(SBWhitelistId::DOWNLOAD, full_hashes); |
| 962 } | 951 } |
| 963 | 952 |
| 964 bool SafeBrowsingDatabaseNew::ContainsInclusionWhitelistedUrl(const GURL& url) { | |
| 965 std::vector<SBFullHash> full_hashes; | |
| 966 UrlToFullHashes(url, true, &full_hashes); | |
| 967 return ContainsWhitelistedHashes(SBWhitelistId::INCLUSION, full_hashes); | |
| 968 } | |
| 969 | |
| 970 bool SafeBrowsingDatabaseNew::ContainsExtensionPrefixes( | 953 bool SafeBrowsingDatabaseNew::ContainsExtensionPrefixes( |
| 971 const std::vector<SBPrefix>& prefixes, | 954 const std::vector<SBPrefix>& prefixes, |
| 972 std::vector<SBPrefix>* prefix_hits) { | 955 std::vector<SBPrefix>* prefix_hits) { |
| 973 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 956 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); |
| 974 | 957 |
| 975 if (!extension_blacklist_store_) | 958 if (!extension_blacklist_store_) |
| 976 return false; | 959 return false; |
| 977 | 960 |
| 978 return MatchAddPrefixes(extension_blacklist_store_.get(), | 961 return MatchAddPrefixes(extension_blacklist_store_.get(), |
| 979 EXTENSIONBLACKLIST % 2, prefixes, prefix_hits); | 962 EXTENSIONBLACKLIST % 2, prefixes, prefix_hits); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1227 return false; | 1210 return false; |
| 1228 } | 1211 } |
| 1229 | 1212 |
| 1230 if (download_whitelist_store_.get() && | 1213 if (download_whitelist_store_.get() && |
| 1231 !download_whitelist_store_->BeginUpdate()) { | 1214 !download_whitelist_store_->BeginUpdate()) { |
| 1232 RecordFailure(FAILURE_WHITELIST_DATABASE_UPDATE_BEGIN); | 1215 RecordFailure(FAILURE_WHITELIST_DATABASE_UPDATE_BEGIN); |
| 1233 HandleCorruptDatabase(); | 1216 HandleCorruptDatabase(); |
| 1234 return false; | 1217 return false; |
| 1235 } | 1218 } |
| 1236 | 1219 |
| 1237 if (inclusion_whitelist_store_.get() && | |
| 1238 !inclusion_whitelist_store_->BeginUpdate()) { | |
| 1239 RecordFailure(FAILURE_WHITELIST_DATABASE_UPDATE_BEGIN); | |
| 1240 HandleCorruptDatabase(); | |
| 1241 return false; | |
| 1242 } | |
| 1243 | |
| 1244 if (extension_blacklist_store_ && | 1220 if (extension_blacklist_store_ && |
| 1245 !extension_blacklist_store_->BeginUpdate()) { | 1221 !extension_blacklist_store_->BeginUpdate()) { |
| 1246 RecordFailure(FAILURE_EXTENSION_BLACKLIST_UPDATE_BEGIN); | 1222 RecordFailure(FAILURE_EXTENSION_BLACKLIST_UPDATE_BEGIN); |
| 1247 HandleCorruptDatabase(); | 1223 HandleCorruptDatabase(); |
| 1248 return false; | 1224 return false; |
| 1249 } | 1225 } |
| 1250 | 1226 |
| 1251 if (ip_blacklist_store_ && !ip_blacklist_store_->BeginUpdate()) { | 1227 if (ip_blacklist_store_ && !ip_blacklist_store_->BeginUpdate()) { |
| 1252 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_BEGIN); | 1228 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_BEGIN); |
| 1253 HandleCorruptDatabase(); | 1229 HandleCorruptDatabase(); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1284 // deprecated. Code to delete the list from the store shows ~15k hits/day as | 1260 // deprecated. Code to delete the list from the store shows ~15k hits/day as |
| 1285 // of Feb 2014, so it has been removed. Everything _should_ be resilient to | 1261 // of Feb 2014, so it has been removed. Everything _should_ be resilient to |
| 1286 // extra data of that sort. | 1262 // extra data of that sort. |
| 1287 UpdateChunkRangesForList(download_store_.get(), kBinUrlList, lists); | 1263 UpdateChunkRangesForList(download_store_.get(), kBinUrlList, lists); |
| 1288 | 1264 |
| 1289 UpdateChunkRangesForList(csd_whitelist_store_.get(), kCsdWhiteList, lists); | 1265 UpdateChunkRangesForList(csd_whitelist_store_.get(), kCsdWhiteList, lists); |
| 1290 | 1266 |
| 1291 UpdateChunkRangesForList(download_whitelist_store_.get(), kDownloadWhiteList, | 1267 UpdateChunkRangesForList(download_whitelist_store_.get(), kDownloadWhiteList, |
| 1292 lists); | 1268 lists); |
| 1293 | 1269 |
| 1294 UpdateChunkRangesForList(inclusion_whitelist_store_.get(), | |
| 1295 kInclusionWhitelist, lists); | |
| 1296 | |
| 1297 UpdateChunkRangesForList(extension_blacklist_store_.get(), | 1270 UpdateChunkRangesForList(extension_blacklist_store_.get(), |
| 1298 kExtensionBlacklist, lists); | 1271 kExtensionBlacklist, lists); |
| 1299 | 1272 |
| 1300 UpdateChunkRangesForList(ip_blacklist_store_.get(), kIPBlacklist, lists); | 1273 UpdateChunkRangesForList(ip_blacklist_store_.get(), kIPBlacklist, lists); |
| 1301 | 1274 |
| 1302 UpdateChunkRangesForList(unwanted_software_store_.get(), kUnwantedUrlList, | 1275 UpdateChunkRangesForList(unwanted_software_store_.get(), kUnwantedUrlList, |
| 1303 lists); | 1276 lists); |
| 1304 | 1277 |
| 1305 UpdateChunkRangesForList(module_whitelist_store_.get(), kModuleWhitelist, | 1278 UpdateChunkRangesForList(module_whitelist_store_.get(), kModuleWhitelist, |
| 1306 lists); | 1279 lists); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1330 DLOG(ERROR) << "Safe-browsing download database corrupt."; | 1303 DLOG(ERROR) << "Safe-browsing download database corrupt."; |
| 1331 | 1304 |
| 1332 if (csd_whitelist_store_.get() && !csd_whitelist_store_->CheckValidity()) | 1305 if (csd_whitelist_store_.get() && !csd_whitelist_store_->CheckValidity()) |
| 1333 DLOG(ERROR) << "Safe-browsing csd whitelist database corrupt."; | 1306 DLOG(ERROR) << "Safe-browsing csd whitelist database corrupt."; |
| 1334 | 1307 |
| 1335 if (download_whitelist_store_.get() && | 1308 if (download_whitelist_store_.get() && |
| 1336 !download_whitelist_store_->CheckValidity()) { | 1309 !download_whitelist_store_->CheckValidity()) { |
| 1337 DLOG(ERROR) << "Safe-browsing download whitelist database corrupt."; | 1310 DLOG(ERROR) << "Safe-browsing download whitelist database corrupt."; |
| 1338 } | 1311 } |
| 1339 | 1312 |
| 1340 if (inclusion_whitelist_store_.get() && | |
| 1341 !inclusion_whitelist_store_->CheckValidity()) { | |
| 1342 DLOG(ERROR) << "Safe-browsing inclusion whitelist database corrupt."; | |
| 1343 } | |
| 1344 | |
| 1345 if (extension_blacklist_store_ && | 1313 if (extension_blacklist_store_ && |
| 1346 !extension_blacklist_store_->CheckValidity()) { | 1314 !extension_blacklist_store_->CheckValidity()) { |
| 1347 DLOG(ERROR) << "Safe-browsing extension blacklist database corrupt."; | 1315 DLOG(ERROR) << "Safe-browsing extension blacklist database corrupt."; |
| 1348 } | 1316 } |
| 1349 | 1317 |
| 1350 if (ip_blacklist_store_ && !ip_blacklist_store_->CheckValidity()) { | 1318 if (ip_blacklist_store_ && !ip_blacklist_store_->CheckValidity()) { |
| 1351 DLOG(ERROR) << "Safe-browsing IP blacklist database corrupt."; | 1319 DLOG(ERROR) << "Safe-browsing IP blacklist database corrupt."; |
| 1352 } | 1320 } |
| 1353 | 1321 |
| 1354 if (unwanted_software_store_ && | 1322 if (unwanted_software_store_ && |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1376 // Track empty updates to answer questions at http://crbug.com/72216 . | 1344 // Track empty updates to answer questions at http://crbug.com/72216 . |
| 1377 if (update_succeeded && !db_state_manager_.change_detected()) | 1345 if (update_succeeded && !db_state_manager_.change_detected()) |
| 1378 UMA_HISTOGRAM_COUNTS("SB2.DatabaseUpdateKilobytes", 0); | 1346 UMA_HISTOGRAM_COUNTS("SB2.DatabaseUpdateKilobytes", 0); |
| 1379 browse_store_->CancelUpdate(); | 1347 browse_store_->CancelUpdate(); |
| 1380 if (download_store_.get()) | 1348 if (download_store_.get()) |
| 1381 download_store_->CancelUpdate(); | 1349 download_store_->CancelUpdate(); |
| 1382 if (csd_whitelist_store_.get()) | 1350 if (csd_whitelist_store_.get()) |
| 1383 csd_whitelist_store_->CancelUpdate(); | 1351 csd_whitelist_store_->CancelUpdate(); |
| 1384 if (download_whitelist_store_.get()) | 1352 if (download_whitelist_store_.get()) |
| 1385 download_whitelist_store_->CancelUpdate(); | 1353 download_whitelist_store_->CancelUpdate(); |
| 1386 if (inclusion_whitelist_store_.get()) | |
| 1387 inclusion_whitelist_store_->CancelUpdate(); | |
| 1388 if (extension_blacklist_store_) | 1354 if (extension_blacklist_store_) |
| 1389 extension_blacklist_store_->CancelUpdate(); | 1355 extension_blacklist_store_->CancelUpdate(); |
| 1390 if (ip_blacklist_store_) | 1356 if (ip_blacklist_store_) |
| 1391 ip_blacklist_store_->CancelUpdate(); | 1357 ip_blacklist_store_->CancelUpdate(); |
| 1392 if (unwanted_software_store_) | 1358 if (unwanted_software_store_) |
| 1393 unwanted_software_store_->CancelUpdate(); | 1359 unwanted_software_store_->CancelUpdate(); |
| 1394 if (module_whitelist_store_) | 1360 if (module_whitelist_store_) |
| 1395 module_whitelist_store_->CancelUpdate(); | 1361 module_whitelist_store_->CancelUpdate(); |
| 1396 if (resource_blacklist_store_) | 1362 if (resource_blacklist_store_) |
| 1397 resource_blacklist_store_->CancelUpdate(); | 1363 resource_blacklist_store_->CancelUpdate(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1408 browse_store_.get(), PrefixSetId::BROWSE, | 1374 browse_store_.get(), PrefixSetId::BROWSE, |
| 1409 FAILURE_BROWSE_DATABASE_UPDATE_FINISH, | 1375 FAILURE_BROWSE_DATABASE_UPDATE_FINISH, |
| 1410 FAILURE_BROWSE_PREFIX_SET_WRITE, true); | 1376 FAILURE_BROWSE_PREFIX_SET_WRITE, true); |
| 1411 | 1377 |
| 1412 UpdateWhitelistStore( | 1378 UpdateWhitelistStore( |
| 1413 CsdWhitelistDBFilename(db_state_manager_.filename_base()), | 1379 CsdWhitelistDBFilename(db_state_manager_.filename_base()), |
| 1414 csd_whitelist_store_.get(), SBWhitelistId::CSD); | 1380 csd_whitelist_store_.get(), SBWhitelistId::CSD); |
| 1415 UpdateWhitelistStore( | 1381 UpdateWhitelistStore( |
| 1416 DownloadWhitelistDBFilename(db_state_manager_.filename_base()), | 1382 DownloadWhitelistDBFilename(db_state_manager_.filename_base()), |
| 1417 download_whitelist_store_.get(), SBWhitelistId::DOWNLOAD); | 1383 download_whitelist_store_.get(), SBWhitelistId::DOWNLOAD); |
| 1418 UpdateWhitelistStore( | |
| 1419 InclusionWhitelistDBFilename(db_state_manager_.filename_base()), | |
| 1420 inclusion_whitelist_store_.get(), SBWhitelistId::INCLUSION); | |
| 1421 | 1384 |
| 1422 if (extension_blacklist_store_) { | 1385 if (extension_blacklist_store_) { |
| 1423 UpdateHashPrefixStore( | 1386 UpdateHashPrefixStore( |
| 1424 ExtensionBlacklistDBFilename(db_state_manager_.filename_base()), | 1387 ExtensionBlacklistDBFilename(db_state_manager_.filename_base()), |
| 1425 extension_blacklist_store_.get(), | 1388 extension_blacklist_store_.get(), |
| 1426 FAILURE_EXTENSION_BLACKLIST_UPDATE_FINISH); | 1389 FAILURE_EXTENSION_BLACKLIST_UPDATE_FINISH); |
| 1427 } | 1390 } |
| 1428 | 1391 |
| 1429 if (ip_blacklist_store_) | 1392 if (ip_blacklist_store_) |
| 1430 UpdateIpBlacklistStore(); | 1393 UpdateIpBlacklistStore(); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1689 csd_whitelist_store_.get() ? csd_whitelist_store_->Delete() : true; | 1652 csd_whitelist_store_.get() ? csd_whitelist_store_->Delete() : true; |
| 1690 if (!r3) | 1653 if (!r3) |
| 1691 RecordFailure(FAILURE_DATABASE_STORE_DELETE); | 1654 RecordFailure(FAILURE_DATABASE_STORE_DELETE); |
| 1692 | 1655 |
| 1693 const bool r4 = download_whitelist_store_.get() | 1656 const bool r4 = download_whitelist_store_.get() |
| 1694 ? download_whitelist_store_->Delete() | 1657 ? download_whitelist_store_->Delete() |
| 1695 : true; | 1658 : true; |
| 1696 if (!r4) | 1659 if (!r4) |
| 1697 RecordFailure(FAILURE_DATABASE_STORE_DELETE); | 1660 RecordFailure(FAILURE_DATABASE_STORE_DELETE); |
| 1698 | 1661 |
| 1699 const bool r5 = inclusion_whitelist_store_.get() | 1662 const bool r5 = true; // Obsolete: inclusion_whitelist_store_ |
|
gab
2016/05/16 13:27:58
Remove this one and re-label other r#'s as they ar
Joe Mason
2016/05/16 14:18:52
Acknowledged.
| |
| 1700 ? inclusion_whitelist_store_->Delete() | |
| 1701 : true; | |
| 1702 if (!r5) | |
| 1703 RecordFailure(FAILURE_DATABASE_STORE_DELETE); | |
| 1704 | 1663 |
| 1705 const base::FilePath browse_filename = | 1664 const base::FilePath browse_filename = |
| 1706 BrowseDBFilename(db_state_manager_.filename_base()); | 1665 BrowseDBFilename(db_state_manager_.filename_base()); |
| 1707 const base::FilePath bloom_filter_filename = | 1666 const base::FilePath bloom_filter_filename = |
| 1708 BloomFilterForFilename(browse_filename); | 1667 BloomFilterForFilename(browse_filename); |
| 1709 const bool r6 = base::DeleteFile(bloom_filter_filename, false); | 1668 const bool r6 = base::DeleteFile(bloom_filter_filename, false); |
| 1710 if (!r6) | 1669 if (!r6) |
| 1711 RecordFailure(FAILURE_DATABASE_FILTER_DELETE); | 1670 RecordFailure(FAILURE_DATABASE_FILTER_DELETE); |
| 1712 | 1671 |
| 1713 const base::FilePath browse_prefix_set_filename = | 1672 const base::FilePath browse_prefix_set_filename = |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1927 | 1886 |
| 1928 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. | 1887 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. |
| 1929 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( | 1888 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( |
| 1930 histogram_name, 1, 1000000, 50, | 1889 histogram_name, 1, 1000000, 50, |
| 1931 base::HistogramBase::kUmaTargetedHistogramFlag); | 1890 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 1932 | 1891 |
| 1933 histogram_pointer->Add(file_size_kilobytes); | 1892 histogram_pointer->Add(file_size_kilobytes); |
| 1934 } | 1893 } |
| 1935 | 1894 |
| 1936 } // namespace safe_browsing | 1895 } // namespace safe_browsing |
| OLD | NEW |