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

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

Issue 2345573002: Each DatabaseManager gets to decide which stores to track (Closed)
Patch Set: Incorporated nparker@ feedback Created 4 years, 3 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 (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 // The Safe Browsing service is responsible for downloading anti-phishing and 5 // The Safe Browsing service is responsible for downloading anti-phishing and
6 // anti-malware tables and checking urls against them. 6 // anti-malware tables and checking urls against them.
7 7
8 #ifndef COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ 8 #ifndef COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_
9 #define COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ 9 #define COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_
10 10
11 #include <deque>
12 #include <map>
13 #include <set> 11 #include <set>
14 #include <string> 12 #include <string>
13 #include <unordered_set>
15 #include <vector> 14 #include <vector>
16 15
17 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
18 #include "base/macros.h" 17 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
20 #include "components/safe_browsing_db/hit_report.h" 19 #include "components/safe_browsing_db/hit_report.h"
21 #include "components/safe_browsing_db/util.h" 20 #include "components/safe_browsing_db/util.h"
22 #include "content/public/common/resource_type.h" 21 #include "content/public/common/resource_type.h"
23 #include "url/gurl.h" 22 #include "url/gurl.h"
24 23
25 namespace net { 24 namespace net {
26 class URLRequestContextGetter; 25 class URLRequestContextGetter;
27 } // namespace net 26 } // namespace net
28 27
29 namespace safe_browsing { 28 namespace safe_browsing {
30 29
30 struct UpdateListIdentifier;
31 struct V4ProtocolConfig; 31 struct V4ProtocolConfig;
32 class V4GetHashProtocolManager; 32 class V4GetHashProtocolManager;
33 33
34 // Base class to either the locally-managed or a remotely-managed database. 34 // Base class to either the locally-managed or a remotely-managed database.
35 class SafeBrowsingDatabaseManager 35 class SafeBrowsingDatabaseManager
36 : public base::RefCountedThreadSafe<SafeBrowsingDatabaseManager> { 36 : public base::RefCountedThreadSafe<SafeBrowsingDatabaseManager> {
37 public: 37 public:
38 // Callers requesting a result should derive from this class. 38 // Callers requesting a result should derive from this class.
39 // The destructor should call db_manager->CancelCheck(client) if a 39 // The destructor should call db_manager->CancelCheck(client) if a
40 // request is still pending. 40 // request is still pending.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 ResultsAreNotCachedOnNull); 214 ResultsAreNotCachedOnNull);
215 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, 215 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
216 GetCachedResults); 216 GetCachedResults);
217 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, 217 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
218 CachedResultsMerged); 218 CachedResultsMerged);
219 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, 219 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest,
220 CachedResultsAreEvicted); 220 CachedResultsAreEvicted);
221 221
222 typedef std::set<SafeBrowsingApiCheck*> ApiCheckSet; 222 typedef std::set<SafeBrowsingApiCheck*> ApiCheckSet;
223 223
224 // Returns the lists that this DatabaseManager should get full hashes for.
225 virtual std::unordered_set<UpdateListIdentifier>
226 GetStoresForFullHashRequests();
227
224 // Called on the IO thread when the SafeBrowsingProtocolManager has received 228 // Called on the IO thread when the SafeBrowsingProtocolManager has received
225 // the full hash and api results for prefixes of the |url| argument in 229 // the full hash and api results for prefixes of the |url| argument in
226 // CheckApiBlacklistUrl. 230 // CheckApiBlacklistUrl.
227 virtual void OnThreatMetadataResponse( 231 virtual void OnThreatMetadataResponse(
228 std::unique_ptr<SafeBrowsingApiCheck> check, 232 std::unique_ptr<SafeBrowsingApiCheck> check,
229 const ThreatMetadata& md); 233 const ThreatMetadata& md);
230 234
231 // In-progress checks. This set owns the SafeBrowsingApiCheck pointers and is 235 // In-progress checks. This set owns the SafeBrowsingApiCheck pointers and is
232 // responsible for deleting them when removing from the set. 236 // responsible for deleting them when removing from the set.
233 ApiCheckSet api_checks_; 237 ApiCheckSet api_checks_;
234 238
235 // Created and destroyed via StartOnIOThread/StopOnIOThread. 239 // Created and destroyed via StartOnIOThread/StopOnIOThread.
236 std::unique_ptr<V4GetHashProtocolManager> v4_get_hash_protocol_manager_; 240 std::unique_ptr<V4GetHashProtocolManager> v4_get_hash_protocol_manager_;
237 241
238 private: 242 private:
239 // Returns an iterator to the pending API check with the given |client|. 243 // Returns an iterator to the pending API check with the given |client|.
240 ApiCheckSet::iterator FindClientApiCheck(Client* client); 244 ApiCheckSet::iterator FindClientApiCheck(Client* client);
241 }; // class SafeBrowsingDatabaseManager 245 }; // class SafeBrowsingDatabaseManager
242 246
243 } // namespace safe_browsing 247 } // namespace safe_browsing
244 248
245 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ 249 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698