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

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: Each DBmanager defines stores to look. base::hash_set -> std::unorderd_set. StoreToFileNameMap -> S… 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Called on the IO thread to check if the given url has blacklisted APIs. 156 // Called on the IO thread to check if the given url has blacklisted APIs.
157 // "client" is called asynchronously with the result when it is ready. Callers 157 // "client" is called asynchronously with the result when it is ready. Callers
158 // should wait for results before calling this method a second time with the 158 // should wait for results before calling this method a second time with the
159 // same client. This method has the same implementation for both the local and 159 // same client. This method has the same implementation for both the local and
160 // remote database managers since it pings Safe Browsing servers directly 160 // remote database managers since it pings Safe Browsing servers directly
161 // without accessing the database at all. Returns true if we can 161 // without accessing the database at all. Returns true if we can
162 // synchronously determine that the url is safe. Otherwise it returns false, 162 // synchronously determine that the url is safe. Otherwise it returns false,
163 // and "client" is called asynchronously with the result when it is ready. 163 // and "client" is called asynchronously with the result when it is ready.
164 virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client); 164 virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client);
165 165
166 // Returns the lists that this DatabaseManager should get full hashes for.
167 virtual std::unordered_set<UpdateListIdentifier>
168 GetStoresForFullHashRequests();
Nathan Parker 2016/09/15 21:12:54 Could this be protected?
vakh (use Gerrit instead) 2016/09/15 21:33:37 Done.
169
166 // Called to initialize objects that are used on the io_thread, such as the 170 // Called to initialize objects that are used on the io_thread, such as the
167 // v4 protocol manager. This may be called multiple times during the life of 171 // v4 protocol manager. This may be called multiple times during the life of
168 // the DatabaseManager. Must be called on IO thread. 172 // the DatabaseManager. Must be called on IO thread.
169 virtual void StartOnIOThread( 173 virtual void StartOnIOThread(
170 net::URLRequestContextGetter* request_context_getter, 174 net::URLRequestContextGetter* request_context_getter,
171 const V4ProtocolConfig& config); 175 const V4ProtocolConfig& config);
172 176
173 // Called to stop or shutdown operations on the io_thread. 177 // Called to stop or shutdown operations on the io_thread.
174 virtual void StopOnIOThread(bool shutdown); 178 virtual void StopOnIOThread(bool shutdown);
175 179
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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