| 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 |
| 11 #include <stddef.h> | 11 #include <stddef.h> |
| 12 | 12 |
| 13 #include <deque> | 13 #include <deque> |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <vector> | 18 #include <vector> |
| 19 | 19 |
| 20 #include "base/callback.h" | 20 #include "base/callback.h" |
| 21 #include "base/containers/hash_tables.h" | |
| 22 #include "base/gtest_prod_util.h" | 21 #include "base/gtest_prod_util.h" |
| 23 #include "base/macros.h" | 22 #include "base/macros.h" |
| 24 #include "base/memory/ref_counted.h" | 23 #include "base/memory/ref_counted.h" |
| 25 #include "base/memory/weak_ptr.h" | 24 #include "base/memory/weak_ptr.h" |
| 26 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
| 27 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 28 #include "chrome/browser/safe_browsing/protocol_manager.h" | 27 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 29 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 28 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 30 #include "components/safe_browsing/common/safe_browsing_prefs.h" | 29 #include "components/safe_browsing/common/safe_browsing_prefs.h" |
| 31 #include "components/safe_browsing_db/database_manager.h" | 30 #include "components/safe_browsing_db/database_manager.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 friend class base::RefCountedThreadSafe<LocalSafeBrowsingDatabaseManager>; | 154 friend class base::RefCountedThreadSafe<LocalSafeBrowsingDatabaseManager>; |
| 156 friend class SafeBrowsingServerTest; | 155 friend class SafeBrowsingServerTest; |
| 157 friend class SafeBrowsingServiceTest; | 156 friend class SafeBrowsingServiceTest; |
| 158 friend class SafeBrowsingServiceTestHelper; | 157 friend class SafeBrowsingServiceTestHelper; |
| 159 friend class LocalDatabaseManagerTest; | 158 friend class LocalDatabaseManagerTest; |
| 160 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest, GetUrlSeverestThreatType); | 159 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest, GetUrlSeverestThreatType); |
| 161 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest, | 160 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest, |
| 162 ServiceStopWithPendingChecks); | 161 ServiceStopWithPendingChecks); |
| 163 | 162 |
| 164 typedef std::vector<SafeBrowsingCheck*> GetHashRequestors; | 163 typedef std::vector<SafeBrowsingCheck*> GetHashRequestors; |
| 165 typedef base::hash_map<SBPrefix, GetHashRequestors> GetHashRequests; | 164 typedef std::map<SBPrefix, GetHashRequestors> GetHashRequests; |
| 166 | 165 |
| 167 // Clients that we've queued up for checking later once the database is ready. | 166 // Clients that we've queued up for checking later once the database is ready. |
| 168 struct QueuedCheck { | 167 struct QueuedCheck { |
| 169 QueuedCheck(const ListType check_type, | 168 QueuedCheck(const ListType check_type, |
| 170 Client* client, | 169 Client* client, |
| 171 const GURL& url, | 170 const GURL& url, |
| 172 const std::vector<SBThreatType>& expected_threats, | 171 const std::vector<SBThreatType>& expected_threats, |
| 173 const base::TimeTicks& start); | 172 const base::TimeTicks& start); |
| 174 QueuedCheck(const QueuedCheck& other); | 173 QueuedCheck(const QueuedCheck& other); |
| 175 ~QueuedCheck(); | 174 ~QueuedCheck(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 375 |
| 377 // Timeout to use for safe browsing checks. | 376 // Timeout to use for safe browsing checks. |
| 378 base::TimeDelta check_timeout_; | 377 base::TimeDelta check_timeout_; |
| 379 | 378 |
| 380 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); | 379 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); |
| 381 }; // class LocalSafeBrowsingDatabaseManager | 380 }; // class LocalSafeBrowsingDatabaseManager |
| 382 | 381 |
| 383 } // namespace safe_browsing | 382 } // namespace safe_browsing |
| 384 | 383 |
| 385 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ | 384 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ |
| OLD | NEW |