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

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

Issue 220493003: Safebrowsing: change gethash caching to match api 2.3 rules, fix some corner cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | Annotate | Revision Log
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 CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ 9 #define CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 std::vector<SBThreatType> url_results; 69 std::vector<SBThreatType> url_results;
70 std::vector<SBFullHash> full_hashes; 70 std::vector<SBFullHash> full_hashes;
71 std::vector<SBThreatType> full_hash_results; 71 std::vector<SBThreatType> full_hash_results;
72 72
73 Client* client; 73 Client* client;
74 bool need_get_hash; 74 bool need_get_hash;
75 base::TimeTicks start; // When check was sent to SB service. 75 base::TimeTicks start; // When check was sent to SB service.
76 safe_browsing_util::ListType check_type; // See comment in constructor. 76 safe_browsing_util::ListType check_type; // See comment in constructor.
77 std::vector<SBThreatType> expected_threats; 77 std::vector<SBThreatType> expected_threats;
78 std::vector<SBPrefix> prefix_hits; 78 std::vector<SBPrefix> prefix_hits;
79 std::vector<SBFullHashResult> full_hits; 79 std::vector<SBFullHashResult> cache_hits;
80 80
81 // Vends weak pointers for TimeoutCallback(). If the response is 81 // Vends weak pointers for TimeoutCallback(). If the response is
82 // received before the timeout fires, factory is destructed and 82 // received before the timeout fires, factory is destructed and
83 // the timeout won't be fired. 83 // the timeout won't be fired.
84 // TODO(lzheng): We should consider to use this time out check 84 // TODO(lzheng): We should consider to use this time out check
85 // for browsing too (instead of implementin in 85 // for browsing too (instead of implementin in
86 // safe_browsing_resource_handler.cc). 86 // safe_browsing_resource_handler.cc).
87 scoped_ptr<base::WeakPtrFactory< 87 scoped_ptr<base::WeakPtrFactory<
88 SafeBrowsingDatabaseManager> > timeout_factory_; 88 SafeBrowsingDatabaseManager> > timeout_factory_;
89 89
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 // Check if the CSD malware IP matching kill switch is turned on. 173 // Check if the CSD malware IP matching kill switch is turned on.
174 virtual bool IsMalwareKillSwitchOn(); 174 virtual bool IsMalwareKillSwitchOn();
175 175
176 // Called on the IO thread to cancel a pending check if the result is no 176 // Called on the IO thread to cancel a pending check if the result is no
177 // longer needed. 177 // longer needed.
178 void CancelCheck(Client* client); 178 void CancelCheck(Client* client);
179 179
180 // Called on the IO thread when the SafeBrowsingProtocolManager has received 180 // Called on the IO thread when the SafeBrowsingProtocolManager has received
181 // the full hash results for prefix hits detected in the database. 181 // the full hash results for prefix hits detected in the database.
182 void HandleGetHashResults( 182 void HandleGetHashResults(SafeBrowsingCheck* check,
183 SafeBrowsingCheck* check, 183 const std::vector<SBFullHashResult>& full_hashes,
184 const std::vector<SBFullHashResult>& full_hashes, 184 const base::TimeDelta& cache_lifetime);
185 bool can_cache);
186 185
187 // Log the user perceived delay caused by SafeBrowsing. This delay is the time 186 // Log the user perceived delay caused by SafeBrowsing. This delay is the time
188 // delta starting from when we would have started reading data from the 187 // delta starting from when we would have started reading data from the
189 // network, and ending when the SafeBrowsing check completes indicating that 188 // network, and ending when the SafeBrowsing check completes indicating that
190 // the current page is 'safe'. 189 // the current page is 'safe'.
191 void LogPauseDelay(base::TimeDelta time); 190 void LogPauseDelay(base::TimeDelta time);
192 191
193 // Called to initialize objects that are used on the io_thread. This may be 192 // Called to initialize objects that are used on the io_thread. This may be
194 // called multiple times during the life of the DatabaseManager. Should be 193 // called multiple times during the life of the DatabaseManager. Should be
195 // called on IO thread. 194 // called on IO thread.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 284
286 // Called on the db thread to close the database. See CloseDatabase(). 285 // Called on the db thread to close the database. See CloseDatabase().
287 void OnCloseDatabase(); 286 void OnCloseDatabase();
288 287
289 // Runs on the db thread to reset the database. We assume that resetting the 288 // Runs on the db thread to reset the database. We assume that resetting the
290 // database is a synchronous operation. 289 // database is a synchronous operation.
291 void OnResetDatabase(); 290 void OnResetDatabase();
292 291
293 // Store in-memory the GetHash response. Runs on the database thread. 292 // Store in-memory the GetHash response. Runs on the database thread.
294 void CacheHashResults(const std::vector<SBPrefix>& prefixes, 293 void CacheHashResults(const std::vector<SBPrefix>& prefixes,
295 const std::vector<SBFullHashResult>& full_hashes); 294 const std::vector<SBFullHashResult>& full_hashes,
295 const base::TimeDelta& cache_lifetime);
296 296
297 // Internal worker function for processing full hashes. 297 // Internal worker function for processing full hashes.
298 void OnHandleGetHashResults(SafeBrowsingCheck* check, 298 void OnHandleGetHashResults(SafeBrowsingCheck* check,
299 const std::vector<SBFullHashResult>& full_hashes); 299 const std::vector<SBFullHashResult>& full_hashes);
300 300
301 // Run one check against |full_hashes|. Returns |true| if the check 301 // Run one check against |full_hashes|. Returns |true| if the check
302 // finds a match in |full_hashes|. 302 // finds a match in |full_hashes|.
303 bool HandleOneCheck(SafeBrowsingCheck* check, 303 bool HandleOneCheck(SafeBrowsingCheck* check,
304 const std::vector<SBFullHashResult>& full_hashes); 304 const std::vector<SBFullHashResult>& full_hashes);
305 305
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 std::deque<QueuedCheck> queued_checks_; 395 std::deque<QueuedCheck> queued_checks_;
396 396
397 // Timeout to use for safe browsing checks. 397 // Timeout to use for safe browsing checks.
398 base::TimeDelta check_timeout_; 398 base::TimeDelta check_timeout_;
399 399
400 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManager); 400 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManager);
401 }; 401 };
402 402
403 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ 403 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/database_manager.cc » ('j') | chrome/browser/safe_browsing/database_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698