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

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

Issue 1881353002: SafeBrowsing: Adds response handler for API blacklist check in Database Manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@osb-impl-1
Patch Set: Review Comments Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/database_manager.h" 5 #include "components/safe_browsing_db/database_manager.h"
6 6
7 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" 7 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "net/url_request/url_request_context_getter.h" 9 #include "net/url_request/url_request_context_getter.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 base::Unretained(this), check)); 79 base::Unretained(this), check));
80 80
81 return false; 81 return false;
82 } 82 }
83 83
84 void SafeBrowsingDatabaseManager::HandleGetHashesWithApisResults( 84 void SafeBrowsingDatabaseManager::HandleGetHashesWithApisResults(
85 std::shared_ptr<SafeBrowsingApiCheck> check, 85 std::shared_ptr<SafeBrowsingApiCheck> check,
86 const std::vector<SBFullHashResult>& full_hash_results, 86 const std::vector<SBFullHashResult>& full_hash_results,
87 const base::TimeDelta& negative_cache_duration) { 87 const base::TimeDelta& negative_cache_duration) {
88 DCHECK_CURRENTLY_ON(BrowserThread::IO); 88 DCHECK_CURRENTLY_ON(BrowserThread::IO);
89 // TODO(kcarattini): Implement response handler. 89 DCHECK(check);
90
91 ThreatMetadata md;
92 // Merge the metadata from all matching results.
93 // TODO(kcarattini): This is O(N^2). Look at improving performance by
94 // using a map, sorting or doing binary search etc..
95 for (const SBFullHashResult& result : full_hash_results) {
96 for (const SBFullHash& full_hash : check->full_hashes()) {
97 if (SBFullHashEqual(full_hash, result.hash)) {
98 md.api_permissions.insert(md.api_permissions.end(),
99 result.metadata.api_permissions.begin(),
100 result.metadata.api_permissions.end());
101 break;
102 }
103 }
104 }
105
106 check->client()->OnCheckApiBlacklistUrlResult(check->url(), md);
90 } 107 }
91 108
92 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck( 109 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck(
93 const GURL& url, const std::vector<SBFullHash>& full_hashes, Client* client) 110 const GURL& url, const std::vector<SBFullHash>& full_hashes, Client* client)
94 : url_(url), full_hashes_(full_hashes), client_(client) { 111 : url_(url), full_hashes_(full_hashes), client_(client) {
95 } 112 }
96 113
97 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() { 114 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() {
98 } 115 }
99 116
100 } // namespace safe_browsing 117 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing_db/database_manager.h ('k') | components/safe_browsing_db/database_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698