| 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 // Safe Browsing Database Manager implementation that manages a local | 5 // Safe Browsing Database Manager implementation that manages a local |
| 6 // database. This is used by Desktop Chromium. | 6 // database. This is used by Desktop Chromium. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/containers/hash_tables.h" | 21 #include "base/containers/hash_tables.h" |
| 22 #include "base/gtest_prod_util.h" | 22 #include "base/gtest_prod_util.h" |
| 23 #include "base/macros.h" | 23 #include "base/macros.h" |
| 24 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
| 25 #include "base/memory/weak_ptr.h" | 25 #include "base/memory/weak_ptr.h" |
| 26 #include "base/synchronization/lock.h" | 26 #include "base/synchronization/lock.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "chrome/browser/safe_browsing/protocol_manager.h" | 28 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 29 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 29 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 30 #include "components/safe_browsing_db/database_manager.h" | 30 #include "components/safe_browsing_db/database_manager.h" |
| 31 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 31 #include "components/safe_browsing_db/safebrowsing.pb.h" | 32 #include "components/safe_browsing_db/safebrowsing.pb.h" |
| 32 #include "components/safe_browsing_db/util.h" | 33 #include "components/safe_browsing_db/util.h" |
| 33 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 34 | 35 |
| 35 namespace net { | 36 namespace net { |
| 36 class URLRequestContext; | 37 class URLRequestContext; |
| 37 class URLRequestContextGetter; | 38 class URLRequestContextGetter; |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace safe_browsing { | 41 namespace safe_browsing { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // hash and metadata of a database record provided the result. They are | 74 // hash and metadata of a database record provided the result. They are |
| 74 // initialized to be empty strings. | 75 // initialized to be empty strings. |
| 75 std::vector<GURL> urls; | 76 std::vector<GURL> urls; |
| 76 std::vector<SBThreatType> url_results; | 77 std::vector<SBThreatType> url_results; |
| 77 std::vector<ThreatMetadata> url_metadata; | 78 std::vector<ThreatMetadata> url_metadata; |
| 78 std::vector<std::string> url_hit_hash; | 79 std::vector<std::string> url_hit_hash; |
| 79 std::vector<SBFullHash> full_hashes; | 80 std::vector<SBFullHash> full_hashes; |
| 80 std::vector<SBThreatType> full_hash_results; | 81 std::vector<SBThreatType> full_hash_results; |
| 81 | 82 |
| 82 SafeBrowsingDatabaseManager::Client* client; | 83 SafeBrowsingDatabaseManager::Client* client; |
| 83 bool is_extended_reporting; | 84 ExtendedReportingLevel extended_reporting_level; |
| 84 bool need_get_hash; | 85 bool need_get_hash; |
| 85 base::TimeTicks start; // When check was sent to SB service. | 86 base::TimeTicks start; // When check was sent to SB service. |
| 86 ListType check_type; // See comment in constructor. | 87 ListType check_type; // See comment in constructor. |
| 87 std::vector<SBThreatType> expected_threats; | 88 std::vector<SBThreatType> expected_threats; |
| 88 std::vector<SBPrefix> prefix_hits; | 89 std::vector<SBPrefix> prefix_hits; |
| 89 std::vector<SBFullHashResult> cache_hits; | 90 std::vector<SBFullHashResult> cache_hits; |
| 90 | 91 |
| 91 // Invoke one of client's callbacks with these results. | 92 // Invoke one of client's callbacks with these results. |
| 92 void OnSafeBrowsingResult(); | 93 void OnSafeBrowsingResult(); |
| 93 | 94 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // Should only be called on db thread as SafeBrowsingDatabase is not | 210 // Should only be called on db thread as SafeBrowsingDatabase is not |
| 210 // threadsafe. | 211 // threadsafe. |
| 211 SafeBrowsingDatabase* GetDatabase(); | 212 SafeBrowsingDatabase* GetDatabase(); |
| 212 | 213 |
| 213 // Called on the IO thread with the check result. | 214 // Called on the IO thread with the check result. |
| 214 void OnCheckDone(SafeBrowsingCheck* info); | 215 void OnCheckDone(SafeBrowsingCheck* info); |
| 215 | 216 |
| 216 // Called on the UI thread to prepare hash request. | 217 // Called on the UI thread to prepare hash request. |
| 217 void OnRequestFullHash(SafeBrowsingCheck* check); | 218 void OnRequestFullHash(SafeBrowsingCheck* check); |
| 218 | 219 |
| 219 // Called on the UI thread to determine if current profile is opted into | 220 // Called on the UI thread to determine what level of extended reporting the |
| 220 // extended reporting. | 221 // current profile is opted into. |
| 221 bool GetExtendedReporting(); | 222 ExtendedReportingLevel GetExtendedReporting(); |
| 222 | 223 |
| 223 // Called on the IO thread to request full hash. | 224 // Called on the IO thread to request full hash. |
| 224 void RequestFullHash(SafeBrowsingCheck* check); | 225 void RequestFullHash(SafeBrowsingCheck* check); |
| 225 | 226 |
| 226 // Called on the database thread to retrieve chunks. | 227 // Called on the database thread to retrieve chunks. |
| 227 void GetAllChunksFromDatabase(GetChunksCallback callback); | 228 void GetAllChunksFromDatabase(GetChunksCallback callback); |
| 228 | 229 |
| 229 // Called on the UI thread to prepare GetAllChunksFromDatabase. | 230 // Called on the UI thread to prepare GetAllChunksFromDatabase. |
| 230 void BeforeGetAllChunksFromDatabase( | 231 void BeforeGetAllChunksFromDatabase( |
| 231 const std::vector<SBListChunkRanges>& lists, | 232 const std::vector<SBListChunkRanges>& lists, |
| 232 bool database_error, | 233 bool database_error, |
| 233 GetChunksCallback callback); | 234 GetChunksCallback callback); |
| 234 | 235 |
| 235 // Called on the IO thread with the results of all chunks. | 236 // Called on the IO thread with the results of all chunks. |
| 236 void OnGetAllChunksFromDatabase(const std::vector<SBListChunkRanges>& lists, | 237 void OnGetAllChunksFromDatabase(const std::vector<SBListChunkRanges>& lists, |
| 237 bool database_error, | 238 bool database_error, |
| 238 bool is_extended_reporting, | 239 ExtendedReportingLevel reporting_level, |
| 239 GetChunksCallback callback); | 240 GetChunksCallback callback); |
| 240 | 241 |
| 241 // Called on the IO thread after the database reports that it added a chunk. | 242 // Called on the IO thread after the database reports that it added a chunk. |
| 242 void OnAddChunksComplete(AddChunksCallback callback); | 243 void OnAddChunksComplete(AddChunksCallback callback); |
| 243 | 244 |
| 244 // Notification that the database is done loading its bloom filter. We may | 245 // Notification that the database is done loading its bloom filter. We may |
| 245 // have had to queue checks until the database is ready, and if so, this | 246 // have had to queue checks until the database is ready, and if so, this |
| 246 // checks them. | 247 // checks them. |
| 247 void DatabaseLoadComplete(); | 248 void DatabaseLoadComplete(); |
| 248 | 249 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 378 |
| 378 // Timeout to use for safe browsing checks. | 379 // Timeout to use for safe browsing checks. |
| 379 base::TimeDelta check_timeout_; | 380 base::TimeDelta check_timeout_; |
| 380 | 381 |
| 381 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); | 382 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); |
| 382 }; // class LocalSafeBrowsingDatabaseManager | 383 }; // class LocalSafeBrowsingDatabaseManager |
| 383 | 384 |
| 384 } // namespace safe_browsing | 385 } // namespace safe_browsing |
| 385 | 386 |
| 386 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ | 387 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ |
| OLD | NEW |