| OLD | NEW |
| 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 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 virtual bool IsMalwareKillSwitchOn() = 0; | 147 virtual bool IsMalwareKillSwitchOn() = 0; |
| 148 | 148 |
| 149 // Check if the CSD whitelist kill switch is turned on. | 149 // Check if the CSD whitelist kill switch is turned on. |
| 150 virtual bool IsCsdWhitelistKillSwitchOn() = 0; | 150 virtual bool IsCsdWhitelistKillSwitchOn() = 0; |
| 151 | 151 |
| 152 // Called on the IO thread to cancel a pending check if the result is no | 152 // Called on the IO thread to cancel a pending check if the result is no |
| 153 // longer needed. Also called after the result has been handled. Api checks | 153 // longer needed. Also called after the result has been handled. Api checks |
| 154 // are handled separately. To cancel an API check use CancelApiCheck. | 154 // are handled separately. To cancel an API check use CancelApiCheck. |
| 155 virtual void CancelCheck(Client* client) = 0; | 155 virtual void CancelCheck(Client* client) = 0; |
| 156 | 156 |
| 157 // TODO(kcarattini): Add a CancelApiCheck method. | 157 // Called on the IO thread to cancel a pending API check if the result is no |
| 158 // longer needed. Returns true if the client was found and the check |
| 159 // successfully cancelled. |
| 160 virtual bool CancelApiCheck(Client* client); |
| 158 | 161 |
| 159 // Called on the IO thread to check if the given url has blacklisted APIs. | 162 // Called on the IO thread to check if the given url has blacklisted APIs. |
| 160 // "client" is called asynchronously with the result when it is ready. | 163 // "client" is called asynchronously with the result when it is ready. Callers |
| 161 // This method has the same implementation for both the local and remote | 164 // should wait for results before calling this method a second time with the |
| 162 // database managers since it pings Safe Browsing servers directly without | 165 // same client. This method has the same implementation for both the local and |
| 163 // accessing the database at all. Returns true if we can synchronously | 166 // remote database managers since it pings Safe Browsing servers directly |
| 164 // determine that the url is safe. Otherwise it returns false, and "client" is | 167 // without accessing the database at all. Returns true if we can |
| 165 // called asynchronously with the result when it is ready. | 168 // synchronously determine that the url is safe. Otherwise it returns false, |
| 169 // and "client" is called asynchronously with the result when it is ready. |
| 166 virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client); | 170 virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client); |
| 167 | 171 |
| 168 // Called to initialize objects that are used on the io_thread, such as the | 172 // Called to initialize objects that are used on the io_thread, such as the |
| 169 // v4 protocol manager. This may be called multiple times during the life of | 173 // v4 protocol manager. This may be called multiple times during the life of |
| 170 // the DatabaseManager. Must be called on IO thread. | 174 // the DatabaseManager. Must be called on IO thread. |
| 171 virtual void StartOnIOThread( | 175 virtual void StartOnIOThread( |
| 172 net::URLRequestContextGetter* request_context_getter, | 176 net::URLRequestContextGetter* request_context_getter, |
| 173 const V4ProtocolConfig& config); | 177 const V4ProtocolConfig& config); |
| 174 | 178 |
| 175 // Called to stop or shutdown operations on the io_thread. | 179 // Called to stop or shutdown operations on the io_thread. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 204 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; | 208 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; |
| 205 | 209 |
| 206 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 210 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 207 CheckApiBlacklistUrlPrefixes); | 211 CheckApiBlacklistUrlPrefixes); |
| 208 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 212 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 209 HandleGetHashesWithApisResults); | 213 HandleGetHashesWithApisResults); |
| 210 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 214 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 211 HandleGetHashesWithApisResultsNoMatch); | 215 HandleGetHashesWithApisResultsNoMatch); |
| 212 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 216 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 213 HandleGetHashesWithApisResultsMatches); | 217 HandleGetHashesWithApisResultsMatches); |
| 218 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 219 CancelApiCheck); |
| 220 |
| 221 typedef std::set<SafeBrowsingApiCheck*> CurrentApiChecks; |
| 222 |
| 223 // In-progress checks. This set owns the SafeBrowsingApiCheck pointers and is |
| 224 // responsible for deleting them when removing from the set. |
| 225 CurrentApiChecks api_checks_; |
| 214 | 226 |
| 215 // Called on the IO thread wheh the SafeBrowsingProtocolManager has received | 227 // Called on the IO thread wheh the SafeBrowsingProtocolManager has received |
| 216 // the full hash and api results for prefixes of the |url| argument in | 228 // the full hash and api results for prefixes of the |url| argument in |
| 217 // CheckApiBlacklistUrl. | 229 // CheckApiBlacklistUrl. |
| 218 virtual void HandleGetHashesWithApisResults( | 230 virtual void HandleGetHashesWithApisResults( |
| 219 std::shared_ptr<SafeBrowsingApiCheck> check, | 231 SafeBrowsingApiCheck* check, |
| 220 const std::vector<SBFullHashResult>& full_hash_results, | 232 const std::vector<SBFullHashResult>& full_hash_results, |
| 221 const base::TimeDelta& negative_cache_duration); | 233 const base::TimeDelta& negative_cache_duration); |
| 222 | 234 |
| 223 // Created and destroyed via StartOnIOThread/StopOnIOThread. | 235 // Created and destroyed via StartOnIOThread/StopOnIOThread. |
| 224 V4GetHashProtocolManager* v4_get_hash_protocol_manager_; | 236 V4GetHashProtocolManager* v4_get_hash_protocol_manager_; |
| 237 |
| 238 private: |
| 239 // Returns an iterator to the pending API check with the given |client|. |
| 240 CurrentApiChecks::iterator FindClientApiCheck(Client* client); |
| 225 }; // class SafeBrowsingDatabaseManager | 241 }; // class SafeBrowsingDatabaseManager |
| 226 | 242 |
| 227 } // namespace safe_browsing | 243 } // namespace safe_browsing |
| 228 | 244 |
| 229 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ | 245 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ |
| OLD | NEW |