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

Side by Side Diff: components/safe_browsing_db/v4_get_hash_protocol_manager.cc

Issue 2915443002: Deprecate NonThreadSafe in components/safe_browsing_db in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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/base64url.h" 9 #include "base/base64url.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 platform_types.insert(store.platform_type()); 248 platform_types.insert(store.platform_type());
249 threat_entry_types.insert(store.threat_entry_type()); 249 threat_entry_types.insert(store.threat_entry_type());
250 threat_types.insert(store.threat_type()); 250 threat_types.insert(store.threat_type());
251 } 251 }
252 platform_types_.assign(platform_types.begin(), platform_types.end()); 252 platform_types_.assign(platform_types.begin(), platform_types.end());
253 threat_entry_types_.assign(threat_entry_types.begin(), 253 threat_entry_types_.assign(threat_entry_types.begin(),
254 threat_entry_types.end()); 254 threat_entry_types.end());
255 threat_types_.assign(threat_types.begin(), threat_types.end()); 255 threat_types_.assign(threat_types.begin(), threat_types.end());
256 } 256 }
257 257
258 V4GetHashProtocolManager::~V4GetHashProtocolManager() {} 258 V4GetHashProtocolManager::~V4GetHashProtocolManager() {
259 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
260 }
259 261
260 void V4GetHashProtocolManager::ClearCache() { 262 void V4GetHashProtocolManager::ClearCache() {
261 DCHECK(CalledOnValidThread()); 263 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
262 full_hash_cache_.clear(); 264 full_hash_cache_.clear();
263 } 265 }
264 266
265 void V4GetHashProtocolManager::GetFullHashes( 267 void V4GetHashProtocolManager::GetFullHashes(
266 const FullHashToStoreAndHashPrefixesMap& 268 const FullHashToStoreAndHashPrefixesMap&
267 full_hash_to_store_and_hash_prefixes, 269 full_hash_to_store_and_hash_prefixes,
268 FullHashCallback callback) { 270 FullHashCallback callback) {
269 DCHECK_CURRENTLY_ON(BrowserThread::IO); 271 DCHECK_CURRENTLY_ON(BrowserThread::IO);
270 DCHECK(CalledOnValidThread()); 272 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
271 DCHECK(!full_hash_to_store_and_hash_prefixes.empty()); 273 DCHECK(!full_hash_to_store_and_hash_prefixes.empty());
272 274
273 std::vector<HashPrefix> prefixes_to_request; 275 std::vector<HashPrefix> prefixes_to_request;
274 std::vector<FullHashInfo> cached_full_hash_infos; 276 std::vector<FullHashInfo> cached_full_hash_infos;
275 GetFullHashCachedResults(full_hash_to_store_and_hash_prefixes, Time::Now(), 277 GetFullHashCachedResults(full_hash_to_store_and_hash_prefixes, Time::Now(),
276 &prefixes_to_request, &cached_full_hash_infos); 278 &prefixes_to_request, &cached_full_hash_infos);
277 279
278 if (prefixes_to_request.empty()) { 280 if (prefixes_to_request.empty()) {
279 // 100% cache hits (positive or negative) so we can call the callback right 281 // 100% cache hits (positive or negative) so we can call the callback right
280 // away. 282 // away.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 501
500 void V4GetHashProtocolManager::GetHashUrlAndHeaders( 502 void V4GetHashProtocolManager::GetHashUrlAndHeaders(
501 const std::string& req_base64, 503 const std::string& req_base64,
502 GURL* gurl, 504 GURL* gurl,
503 net::HttpRequestHeaders* headers) const { 505 net::HttpRequestHeaders* headers) const {
504 V4ProtocolManagerUtil::GetRequestUrlAndHeaders(req_base64, "fullHashes:find", 506 V4ProtocolManagerUtil::GetRequestUrlAndHeaders(req_base64, "fullHashes:find",
505 config_, gurl, headers); 507 config_, gurl, headers);
506 } 508 }
507 509
508 void V4GetHashProtocolManager::HandleGetHashError(const Time& now) { 510 void V4GetHashProtocolManager::HandleGetHashError(const Time& now) {
509 DCHECK(CalledOnValidThread()); 511 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
510 TimeDelta next = V4ProtocolManagerUtil::GetNextBackOffInterval( 512 TimeDelta next = V4ProtocolManagerUtil::GetNextBackOffInterval(
511 &gethash_error_count_, &gethash_back_off_mult_); 513 &gethash_error_count_, &gethash_back_off_mult_);
512 next_gethash_time_ = now + next; 514 next_gethash_time_ = now + next;
513 } 515 }
514 516
515 void V4GetHashProtocolManager::OnFullHashForApi( 517 void V4GetHashProtocolManager::OnFullHashForApi(
516 const ThreatMetadataForApiCallback& api_callback, 518 const ThreatMetadataForApiCallback& api_callback,
517 const std::vector<FullHash>& full_hashes, 519 const std::vector<FullHash>& full_hashes,
518 const std::vector<FullHashInfo>& full_hash_infos) { 520 const std::vector<FullHashInfo>& full_hash_infos) {
519 ThreatMetadata md; 521 ThreatMetadata md;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } else { 733 } else {
732 RecordV4GetHashCheckResult(GET_HASH_CHECK_MISS); 734 RecordV4GetHashCheckResult(GET_HASH_CHECK_MISS);
733 } 735 }
734 } 736 }
735 737
736 // net::URLFetcherDelegate implementation ---------------------------------- 738 // net::URLFetcherDelegate implementation ----------------------------------
737 739
738 // SafeBrowsing request responses are handled here. 740 // SafeBrowsing request responses are handled here.
739 void V4GetHashProtocolManager::OnURLFetchComplete( 741 void V4GetHashProtocolManager::OnURLFetchComplete(
740 const net::URLFetcher* source) { 742 const net::URLFetcher* source) {
741 DCHECK(CalledOnValidThread()); 743 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
742 DCHECK_CURRENTLY_ON(BrowserThread::IO); 744 DCHECK_CURRENTLY_ON(BrowserThread::IO);
743 745
744 PendingHashRequests::iterator it = pending_hash_requests_.find(source); 746 PendingHashRequests::iterator it = pending_hash_requests_.find(source);
745 DCHECK(it != pending_hash_requests_.end()) << "Request not found"; 747 DCHECK(it != pending_hash_requests_.end()) << "Request not found";
746 748
747 int response_code = source->GetResponseCode(); 749 int response_code = source->GetResponseCode();
748 net::URLRequestStatus status = source->GetStatus(); 750 net::URLRequestStatus status = source->GetStatus();
749 V4ProtocolManagerUtil::RecordHttpResponseOrErrorCode( 751 V4ProtocolManagerUtil::RecordHttpResponseOrErrorCode(
750 "SafeBrowsing.V4GetHash.Network.Result", status, response_code); 752 "SafeBrowsing.V4GetHash.Network.Result", status, response_code);
751 753
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 std::ostream& operator<<(std::ostream& os, const FullHashInfo& fhi) { 792 std::ostream& operator<<(std::ostream& os, const FullHashInfo& fhi) {
791 os << "{full_hash: " << fhi.full_hash << "; list_id: " << fhi.list_id 793 os << "{full_hash: " << fhi.full_hash << "; list_id: " << fhi.list_id
792 << "; positive_expiry: " << fhi.positive_expiry 794 << "; positive_expiry: " << fhi.positive_expiry
793 << "; metadata.api_permissions.size(): " 795 << "; metadata.api_permissions.size(): "
794 << fhi.metadata.api_permissions.size() << "}"; 796 << fhi.metadata.api_permissions.size() << "}";
795 return os; 797 return os;
796 } 798 }
797 #endif 799 #endif
798 800
799 } // namespace safe_browsing 801 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing_db/v4_get_hash_protocol_manager.h ('k') | components/safe_browsing_db/v4_update_protocol_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698