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

Unified Diff: chrome/browser/safe_browsing/download_protection_service.h

Issue 8345033: Collect some histograms about signed binary downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
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_;

Powered by Google App Engine
This is Rietveld 408576698