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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 client_callback_type(client_callback_type), | 121 client_callback_type(client_callback_type), |
122 result_threat_type(SB_THREAT_TYPE_SAFE), | 122 result_threat_type(SB_THREAT_TYPE_SAFE), |
123 stores_to_check(stores_to_check) { | 123 stores_to_check(stores_to_check) { |
124 full_hashes.assign(full_hashes_set.begin(), full_hashes_set.end()); | 124 full_hashes.assign(full_hashes_set.begin(), full_hashes_set.end()); |
125 } | 125 } |
126 | 126 |
127 V4LocalDatabaseManager::PendingCheck::~PendingCheck() {} | 127 V4LocalDatabaseManager::PendingCheck::~PendingCheck() {} |
128 | 128 |
129 // static | 129 // static |
130 scoped_refptr<V4LocalDatabaseManager> V4LocalDatabaseManager::Create( | 130 scoped_refptr<V4LocalDatabaseManager> V4LocalDatabaseManager::Create( |
131 const base::FilePath& base_path) { | 131 const base::FilePath& base_path, |
| 132 ExtendedReportingLevelCallback extended_reporting_level_callback) { |
132 if (!V4FeatureList::IsLocalDatabaseManagerEnabled()) { | 133 if (!V4FeatureList::IsLocalDatabaseManagerEnabled()) { |
133 return nullptr; | 134 return nullptr; |
134 } | 135 } |
135 | 136 |
136 return make_scoped_refptr(new V4LocalDatabaseManager(base_path)); | 137 return make_scoped_refptr( |
| 138 new V4LocalDatabaseManager(base_path, extended_reporting_level_callback)); |
137 } | 139 } |
138 | 140 |
139 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) | 141 V4LocalDatabaseManager::V4LocalDatabaseManager( |
| 142 const base::FilePath& base_path, |
| 143 ExtendedReportingLevelCallback extended_reporting_level_callback) |
140 : base_path_(base_path), | 144 : base_path_(base_path), |
| 145 extended_reporting_level_callback_(extended_reporting_level_callback), |
141 list_infos_(GetListInfos()), | 146 list_infos_(GetListInfos()), |
142 weak_factory_(this) { | 147 weak_factory_(this) { |
143 DCHECK(!base_path_.empty()); | 148 DCHECK(!base_path_.empty()); |
144 DCHECK(!list_infos_.empty()); | 149 DCHECK(!list_infos_.empty()); |
145 | 150 |
146 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " | 151 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " |
147 << "base_path_: " << base_path_.AsUTF8Unsafe(); | 152 << "base_path_: " << base_path_.AsUTF8Unsafe(); |
148 } | 153 } |
149 | 154 |
150 V4LocalDatabaseManager::~V4LocalDatabaseManager() { | 155 V4LocalDatabaseManager::~V4LocalDatabaseManager() { |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 // has been created, swap it out on the IO thread. | 705 // has been created, swap it out on the IO thread. |
701 NewDatabaseReadyCallback db_ready_callback = | 706 NewDatabaseReadyCallback db_ready_callback = |
702 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForChecks, | 707 base::Bind(&V4LocalDatabaseManager::DatabaseReadyForChecks, |
703 weak_factory_.GetWeakPtr()); | 708 weak_factory_.GetWeakPtr()); |
704 V4Database::Create(task_runner_, base_path_, list_infos_, db_ready_callback); | 709 V4Database::Create(task_runner_, base_path_, list_infos_, db_ready_callback); |
705 } | 710 } |
706 | 711 |
707 void V4LocalDatabaseManager::SetupUpdateProtocolManager( | 712 void V4LocalDatabaseManager::SetupUpdateProtocolManager( |
708 net::URLRequestContextGetter* request_context_getter, | 713 net::URLRequestContextGetter* request_context_getter, |
709 const V4ProtocolConfig& config) { | 714 const V4ProtocolConfig& config) { |
710 V4UpdateCallback callback = | 715 V4UpdateCallback update_callback = |
711 base::Bind(&V4LocalDatabaseManager::UpdateRequestCompleted, | 716 base::Bind(&V4LocalDatabaseManager::UpdateRequestCompleted, |
712 weak_factory_.GetWeakPtr()); | 717 weak_factory_.GetWeakPtr()); |
713 | 718 |
714 v4_update_protocol_manager_ = | 719 v4_update_protocol_manager_ = V4UpdateProtocolManager::Create( |
715 V4UpdateProtocolManager::Create(request_context_getter, config, callback); | 720 request_context_getter, config, update_callback, |
| 721 extended_reporting_level_callback_); |
716 } | 722 } |
717 | 723 |
718 void V4LocalDatabaseManager::UpdateRequestCompleted( | 724 void V4LocalDatabaseManager::UpdateRequestCompleted( |
719 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 725 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
720 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 726 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
721 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 727 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
722 db_updated_callback_); | 728 db_updated_callback_); |
723 } | 729 } |
724 | 730 |
725 bool V4LocalDatabaseManager::AreStoresAvailableNow( | 731 bool V4LocalDatabaseManager::AreStoresAvailableNow( |
726 const StoresToCheck& stores_to_check) const { | 732 const StoresToCheck& stores_to_check) const { |
727 return enabled_ && v4_database_ && | 733 return enabled_ && v4_database_ && |
728 v4_database_->AreStoresAvailable(stores_to_check); | 734 v4_database_->AreStoresAvailable(stores_to_check); |
729 } | 735 } |
730 | 736 |
731 } // namespace safe_browsing | 737 } // namespace safe_browsing |
OLD | NEW |