Chromium Code Reviews| 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 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 url_fetcher_id_(0) { | 115 url_fetcher_id_(0) { |
| 116 } | 116 } |
| 117 | 117 |
| 118 V4GetHashProtocolManager::~V4GetHashProtocolManager() { | 118 V4GetHashProtocolManager::~V4GetHashProtocolManager() { |
| 119 // Delete in-progress SafeBrowsing requests. | 119 // Delete in-progress SafeBrowsing requests. |
| 120 STLDeleteContainerPairFirstPointers(hash_requests_.begin(), | 120 STLDeleteContainerPairFirstPointers(hash_requests_.begin(), |
| 121 hash_requests_.end()); | 121 hash_requests_.end()); |
| 122 hash_requests_.clear(); | 122 hash_requests_.clear(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // static | |
| 126 void V4GetHashProtocolManager::RegisterFactory( | |
| 127 std::unique_ptr<V4GetHashProtocolManagerFactory> factory) { | |
| 128 if (factory_) | |
| 129 delete factory_; | |
| 130 factory_ = factory.release(); | |
|
mattm
2016/05/02 22:36:53
If you do switch to passing in a unique_ptr, why n
Reilly Grant (use Gerrit)
2016/05/02 22:55:27
factory_ is a global variable. It must be a primit
| |
| 131 } | |
| 132 | |
| 125 std::string V4GetHashProtocolManager::GetHashRequest( | 133 std::string V4GetHashProtocolManager::GetHashRequest( |
| 126 const std::vector<SBPrefix>& prefixes, | 134 const std::vector<SBPrefix>& prefixes, |
| 127 const std::vector<PlatformType>& platforms, | 135 const std::vector<PlatformType>& platforms, |
| 128 ThreatType threat_type) { | 136 ThreatType threat_type) { |
| 129 // Build the request. Client info and client states are not added to the | 137 // Build the request. Client info and client states are not added to the |
| 130 // request protocol buffer. Client info is passed as params in the url. | 138 // request protocol buffer. Client info is passed as params in the url. |
| 131 FindFullHashesRequest req; | 139 FindFullHashesRequest req; |
| 132 ThreatInfo* info = req.mutable_threat_info(); | 140 ThreatInfo* info = req.mutable_threat_info(); |
| 133 info->add_threat_types(threat_type); | 141 info->add_threat_types(threat_type); |
| 134 info->add_threat_entry_types(URL_EXPRESSION); | 142 info->add_threat_entry_types(URL_EXPRESSION); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 next_gethash_time_ = now + next; | 347 next_gethash_time_ = now + next; |
| 340 } | 348 } |
| 341 | 349 |
| 342 GURL V4GetHashProtocolManager::GetHashUrl(const std::string& req_base64) const { | 350 GURL V4GetHashProtocolManager::GetHashUrl(const std::string& req_base64) const { |
| 343 return V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedFullHashes", | 351 return V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedFullHashes", |
| 344 config_); | 352 config_); |
| 345 } | 353 } |
| 346 | 354 |
| 347 | 355 |
| 348 } // namespace safe_browsing | 356 } // namespace safe_browsing |
| OLD | NEW |