| Index: chrome/browser/safe_browsing/download_protection_service.h
|
| ===================================================================
|
| --- chrome/browser/safe_browsing/download_protection_service.h (revision 106761)
|
| +++ chrome/browser/safe_browsing/download_protection_service.h (working copy)
|
| @@ -32,13 +32,12 @@
|
|
|
| // This class provides an asynchronous API to check whether a particular
|
| // client download is malicious or not.
|
| -class DownloadProtectionService
|
| - : public base::RefCountedThreadSafe<DownloadProtectionService>,
|
| - public URLFetcher::Delegate {
|
| +class DownloadProtectionService : public URLFetcher::Delegate {
|
| public:
|
| - // TODO(noelutz): we're missing some fields here: filename to get
|
| - // the signature, server IPs, tab URL redirect chain, ...
|
| + // TODO(noelutz): we're missing some fields here: server IPs,
|
| + // tab URL redirect chain, ...
|
| struct DownloadInfo {
|
| + FilePath local_file;
|
| std::vector<GURL> download_url_chain;
|
| GURL referrer_url;
|
| std::string sha256_hash;
|
| @@ -65,6 +64,9 @@
|
| SafeBrowsingService* sb_service,
|
| net::URLRequestContextGetter* request_context_getter);
|
|
|
| + // Note: This class may _only_ be deleted on the IO thread!
|
| + virtual ~DownloadProtectionService();
|
| +
|
| // From the URLFetcher::Delegate interface.
|
| virtual void OnURLFetchComplete(const URLFetcher* source,
|
| const GURL& url,
|
| @@ -107,11 +109,10 @@
|
| REASON_INVALID_REQUEST_PROTO,
|
| REASON_SERVER_PING_FAILED,
|
| REASON_INVALID_RESPONSE_PROTO,
|
| + REASON_NOT_BINARY_FILE,
|
| REASON_MAX // Always add new values before this one.
|
| };
|
|
|
| - virtual ~DownloadProtectionService();
|
| -
|
| private:
|
| friend class base::RefCountedThreadSafe<DownloadProtectionService>;
|
| friend class DownloadProtectionServiceTest;
|
| @@ -124,10 +125,20 @@
|
|
|
| static const char kDownloadRequestUrl[];
|
|
|
| + // Extracts features from the downloaded file. Runs in the file thread.
|
| + // When finished, invokes StartCheckClientDownload on the IO thread.
|
| + // |pingback_enabled| contains the value of |enabled_| when
|
| + // CheckClientDownload was called; this is because enabled_ can only be
|
| + // accessed on the UI thread.
|
| + void ExtractFileFeatures(const DownloadInfo& info,
|
| + bool pingback_enabled,
|
| + const CheckDownloadCallback& callback);
|
| +
|
| // Same as above but this method is called on the IO thread after we have
|
| // done some basic checks to see whether the download is definitely not
|
| // safe.
|
| void StartCheckClientDownload(const DownloadInfo& info,
|
| + bool pingback_enabled,
|
| const CheckDownloadCallback& callback);
|
|
|
| // This function must run on the UI thread and will invoke the callback
|
| @@ -142,7 +153,8 @@
|
| void SetEnabledOnIOThread(bool enableed);
|
|
|
| // This pointer may be NULL if SafeBrowsing is disabled.
|
| - scoped_refptr<SafeBrowsingService> sb_service_;
|
| + // The SafeBrowsingService owns us.
|
| + SafeBrowsingService* sb_service_;
|
|
|
| // The context we use to issue network requests.
|
| scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
|
|
|