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

Side by Side Diff: chrome/browser/safe_browsing/local_database_manager.h

Issue 1848973004: Makes V4UpdateProtocolManager auto-schedule update fetching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v4_01_
Patch Set: git fetch && git pull && gclient sync Created 4 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/local_database_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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
21 #include "base/gtest_prod_util.h" 21 #include "base/gtest_prod_util.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/ref_counted.h" 23 #include "base/memory/ref_counted.h"
24 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.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/safebrowsing.pb.h"
31 #include "components/safe_browsing_db/util.h" 32 #include "components/safe_browsing_db/util.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 34
34 namespace net { 35 namespace net {
35 class URLRequestContext; 36 class URLRequestContext;
36 class URLRequestContextGetter; 37 class URLRequestContextGetter;
37 } 38 }
38 39
39 namespace safe_browsing { 40 namespace safe_browsing {
40 41
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 std::vector<SBThreatType> url_results; 76 std::vector<SBThreatType> url_results;
76 std::vector<ThreatMetadata> url_metadata; 77 std::vector<ThreatMetadata> url_metadata;
77 std::vector<std::string> url_hit_hash; 78 std::vector<std::string> url_hit_hash;
78 std::vector<SBFullHash> full_hashes; 79 std::vector<SBFullHash> full_hashes;
79 std::vector<SBThreatType> full_hash_results; 80 std::vector<SBThreatType> full_hash_results;
80 81
81 SafeBrowsingDatabaseManager::Client* client; 82 SafeBrowsingDatabaseManager::Client* client;
82 bool is_extended_reporting; 83 bool is_extended_reporting;
83 bool need_get_hash; 84 bool need_get_hash;
84 base::TimeTicks start; // When check was sent to SB service. 85 base::TimeTicks start; // When check was sent to SB service.
85 ListType check_type; // See comment in constructor. 86 ListType check_type; // See comment in constructor.
86 std::vector<SBThreatType> expected_threats; 87 std::vector<SBThreatType> expected_threats;
87 std::vector<SBPrefix> prefix_hits; 88 std::vector<SBPrefix> prefix_hits;
88 std::vector<SBFullHashResult> cache_hits; 89 std::vector<SBFullHashResult> cache_hits;
89 90
90 // Invoke one of client's callbacks with these results. 91 // Invoke one of client's callbacks with these results.
91 void OnSafeBrowsingResult(); 92 void OnSafeBrowsingResult();
92 93
93 // Vends weak pointers for async callbacks on the IO thread, such as 94 // Vends weak pointers for async callbacks on the IO thread, such as
94 // timeout checks and replies from checks performed on the SB task runner. 95 // timeout checks and replies from checks performed on the SB task runner.
95 // TODO(lzheng): We should consider to use this time out check 96 // TODO(lzheng): We should consider to use this time out check
(...skipping 28 matching lines...) Expand all
124 bool CheckResourceUrl(const GURL& url, Client* client) override; 125 bool CheckResourceUrl(const GURL& url, Client* client) override;
125 bool MatchCsdWhitelistUrl(const GURL& url) override; 126 bool MatchCsdWhitelistUrl(const GURL& url) override;
126 bool MatchMalwareIP(const std::string& ip_address) override; 127 bool MatchMalwareIP(const std::string& ip_address) override;
127 bool MatchDownloadWhitelistUrl(const GURL& url) override; 128 bool MatchDownloadWhitelistUrl(const GURL& url) override;
128 bool MatchDownloadWhitelistString(const std::string& str) override; 129 bool MatchDownloadWhitelistString(const std::string& str) override;
129 bool MatchInclusionWhitelistUrl(const GURL& url) override; 130 bool MatchInclusionWhitelistUrl(const GURL& url) override;
130 bool MatchModuleWhitelistString(const std::string& str) override; 131 bool MatchModuleWhitelistString(const std::string& str) override;
131 bool IsMalwareKillSwitchOn() override; 132 bool IsMalwareKillSwitchOn() override;
132 bool IsCsdWhitelistKillSwitchOn() override; 133 bool IsCsdWhitelistKillSwitchOn() override;
133 void CancelCheck(Client* client) override; 134 void CancelCheck(Client* client) override;
134 void StartOnIOThread( 135 void StartOnIOThread(net::URLRequestContextGetter* request_context_getter,
135 net::URLRequestContextGetter* request_context_getter, 136 const V4ProtocolConfig& config) override;
136 const V4ProtocolConfig& config) override;
137 void StopOnIOThread(bool shutdown) override; 137 void StopOnIOThread(bool shutdown) override;
138 bool download_protection_enabled() const override; 138 bool download_protection_enabled() const override;
139 139
140 protected: 140 protected:
141 ~LocalSafeBrowsingDatabaseManager() override; 141 ~LocalSafeBrowsingDatabaseManager() override;
142 142
143 // protected for tests. 143 // protected for tests.
144 void NotifyDatabaseUpdateFinished(bool update_succeeded); 144 void NotifyDatabaseUpdateFinished(bool update_succeeded);
145 145
146 private: 146 private:
147 // Called on the IO thread when the SafeBrowsingProtocolManager has received 147 // Called on the IO thread when the SafeBrowsingProtocolManager has received
148 // the full hash results for prefix hits detected in the database. 148 // the full hash results for prefix hits detected in the database.
149 void HandleGetHashResults(SafeBrowsingCheck* check, 149 void HandleGetHashResults(SafeBrowsingCheck* check,
150 const std::vector<SBFullHashResult>& full_hashes, 150 const std::vector<SBFullHashResult>& full_hashes,
151 const base::TimeDelta& cache_lifetime); 151 const base::TimeDelta& cache_lifetime);
152 152
153 friend class base::RefCountedThreadSafe<LocalSafeBrowsingDatabaseManager>; 153 friend class base::RefCountedThreadSafe<LocalSafeBrowsingDatabaseManager>;
154 friend class SafeBrowsingServerTest; 154 friend class SafeBrowsingServerTest;
155 friend class SafeBrowsingServiceTest; 155 friend class SafeBrowsingServiceTest;
156 friend class SafeBrowsingServiceTestHelper; 156 friend class SafeBrowsingServiceTestHelper;
157 friend class LocalDatabaseManagerTest; 157 friend class LocalDatabaseManagerTest;
158 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest, 158 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest, GetUrlSeverestThreatType);
159 GetUrlSeverestThreatType);
160 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest, 159 FRIEND_TEST_ALL_PREFIXES(LocalDatabaseManagerTest,
161 ServiceStopWithPendingChecks); 160 ServiceStopWithPendingChecks);
162 161
163 typedef std::set<SafeBrowsingCheck*> CurrentChecks; 162 typedef std::set<SafeBrowsingCheck*> CurrentChecks;
164 typedef std::vector<SafeBrowsingCheck*> GetHashRequestors; 163 typedef std::vector<SafeBrowsingCheck*> GetHashRequestors;
165 typedef base::hash_map<SBPrefix, GetHashRequestors> GetHashRequests; 164 typedef base::hash_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,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // checks them. 248 // checks them.
250 void DatabaseLoadComplete(); 249 void DatabaseLoadComplete();
251 250
252 // Called on the database thread to add/remove chunks and host keys. 251 // Called on the database thread to add/remove chunks and host keys.
253 void AddDatabaseChunks( 252 void AddDatabaseChunks(
254 const std::string& list, 253 const std::string& list,
255 scoped_ptr<std::vector<scoped_ptr<SBChunkData>>> chunks, 254 scoped_ptr<std::vector<scoped_ptr<SBChunkData>>> chunks,
256 AddChunksCallback callback); 255 AddChunksCallback callback);
257 256
258 void DeleteDatabaseChunks( 257 void DeleteDatabaseChunks(
259 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes); 258 scoped_ptr<std::vector<SBChunkDelete>> chunk_deletes);
260 259
261 void NotifyClientBlockingComplete(Client* client, bool proceed); 260 void NotifyClientBlockingComplete(Client* client, bool proceed);
262 261
263 void DatabaseUpdateFinished(bool update_succeeded); 262 void DatabaseUpdateFinished(bool update_succeeded);
264 263
265 // Called on the db thread to close the database. See CloseDatabase(). 264 // Called on the db thread to close the database. See CloseDatabase().
266 void OnCloseDatabase(); 265 void OnCloseDatabase();
267 266
268 // Runs on the db thread to reset the database. We assume that resetting the 267 // Runs on the db thread to reset the database. We assume that resetting the
269 // database is a synchronous operation. 268 // database is a synchronous operation.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 378
380 // Timeout to use for safe browsing checks. 379 // Timeout to use for safe browsing checks.
381 base::TimeDelta check_timeout_; 380 base::TimeDelta check_timeout_;
382 381
383 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); 382 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager);
384 }; // class LocalSafeBrowsingDatabaseManager 383 }; // class LocalSafeBrowsingDatabaseManager
385 384
386 } // namespace safe_browsing 385 } // namespace safe_browsing
387 386
388 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ 387 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/local_database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698