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

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

Issue 7313003: Separate memory purger from safe browsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SAFE_BROWSING_SERVICE_H_ 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
10 #pragma once 10 #pragma once
11 11
12 #include <deque> 12 #include <deque>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/hash_tables.h" 17 #include "base/hash_tables.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/task.h" 21 #include "base/task.h"
22 #include "base/time.h" 22 #include "base/time.h"
23 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 23 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
24 #include "content/common/notification_observer.h"
25 #include "content/common/notification_registrar.h"
24 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
25 27
26 class MalwareDetails; 28 class MalwareDetails;
27 class PrefService; 29 class PrefService;
28 class SafeBrowsingDatabase; 30 class SafeBrowsingDatabase;
29 class SafeBrowsingProtocolManager; 31 class SafeBrowsingProtocolManager;
30 class SafeBrowsingServiceFactory; 32 class SafeBrowsingServiceFactory;
31 33
32 namespace base { 34 namespace base {
33 class Thread; 35 class Thread;
34 } 36 }
35 37
36 namespace net { 38 namespace net {
37 class URLRequestContextGetter; 39 class URLRequestContextGetter;
38 } 40 }
39 41
40 // Construction needs to happen on the main thread. 42 // Construction needs to happen on the main thread.
41 class SafeBrowsingService 43 class SafeBrowsingService
42 : public base::RefCountedThreadSafe<SafeBrowsingService> { 44 : public base::RefCountedThreadSafe<SafeBrowsingService>,
45 public NotificationObserver {
43 public: 46 public:
44 class Client; 47 class Client;
45 // Users of this service implement this interface to be notified 48 // Users of this service implement this interface to be notified
46 // asynchronously of the result. 49 // asynchronously of the result.
47 enum UrlCheckResult { 50 enum UrlCheckResult {
48 SAFE, 51 SAFE,
49 URL_PHISHING, 52 URL_PHISHING,
50 URL_MALWARE, 53 URL_MALWARE,
51 BINARY_MALWARE_URL, // Binary url leads to a malware. 54 BINARY_MALWARE_URL, // Binary url leads to a malware.
52 BINARY_MALWARE_HASH, // Binary hash indicates this is a malware. 55 BINARY_MALWARE_HASH, // Binary hash indicates this is a malware.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // browsing check with timeout of |timeout_ms|. |task| will be called upon 406 // browsing check with timeout of |timeout_ms|. |task| will be called upon
404 // success, otherwise TimeoutCallback will be called. 407 // success, otherwise TimeoutCallback will be called.
405 void StartDownloadCheck(SafeBrowsingCheck* check, 408 void StartDownloadCheck(SafeBrowsingCheck* check,
406 Client* client, 409 Client* client,
407 CancelableTask* task, 410 CancelableTask* task,
408 int64 timeout_ms); 411 int64 timeout_ms);
409 412
410 // Adds the given entry to the whitelist. Called on the UI thread. 413 // Adds the given entry to the whitelist. Called on the UI thread.
411 void UpdateWhitelist(const UnsafeResource& resource); 414 void UpdateWhitelist(const UnsafeResource& resource);
412 415
416 // NotificationObserver override
417 virtual void Observe(NotificationType type,
418 const NotificationSource& source,
419 const NotificationDetails& details) OVERRIDE;
420
413 // The factory used to instanciate a SafeBrowsingService object. 421 // The factory used to instanciate a SafeBrowsingService object.
414 // Useful for tests, so they can provide their own implementation of 422 // Useful for tests, so they can provide their own implementation of
415 // SafeBrowsingService. 423 // SafeBrowsingService.
416 static SafeBrowsingServiceFactory* factory_; 424 static SafeBrowsingServiceFactory* factory_;
417 425
418 CurrentChecks checks_; 426 CurrentChecks checks_;
419 427
420 // Used for issuing only one GetHash request for a given prefix. 428 // Used for issuing only one GetHash request for a given prefix.
421 GetHashRequests gethash_requests_; 429 GetHashRequests gethash_requests_;
422 430
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 473
466 std::deque<QueuedCheck> queued_checks_; 474 std::deque<QueuedCheck> queued_checks_;
467 475
468 // When download url check takes this long, client's callback will be called 476 // When download url check takes this long, client's callback will be called
469 // without waiting for the result. 477 // without waiting for the result.
470 int64 download_urlcheck_timeout_ms_; 478 int64 download_urlcheck_timeout_ms_;
471 479
472 // Similar to |download_urlcheck_timeout_ms_|, but for download hash checks. 480 // Similar to |download_urlcheck_timeout_ms_|, but for download hash checks.
473 int64 download_hashcheck_timeout_ms_; 481 int64 download_hashcheck_timeout_ms_;
474 482
483 NotificationRegistrar registrar_;
484
475 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); 485 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService);
476 }; 486 };
477 487
478 // Factory for creating SafeBrowsingService. Useful for tests. 488 // Factory for creating SafeBrowsingService. Useful for tests.
479 class SafeBrowsingServiceFactory { 489 class SafeBrowsingServiceFactory {
480 public: 490 public:
481 SafeBrowsingServiceFactory() { } 491 SafeBrowsingServiceFactory() { }
482 virtual ~SafeBrowsingServiceFactory() { } 492 virtual ~SafeBrowsingServiceFactory() { }
483 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; 493 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0;
484 private: 494 private:
485 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); 495 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory);
486 }; 496 };
487 497
488 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 498 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698