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

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

Issue 663023007: Include high-fidelity metadata about a download in incident reports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: skip on shutdown Created 6 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
diff --git a/chrome/browser/safe_browsing/download_protection_service.h b/chrome/browser/safe_browsing/download_protection_service.h
index 070c9a388d60f8f306e2634c0d0b10ec49cb0483..a42addde6050fa45f5ee9fd5124b5bc485e31d59 100644
--- a/chrome/browser/safe_browsing/download_protection_service.h
+++ b/chrome/browser/safe_browsing/download_protection_service.h
@@ -14,9 +14,11 @@
#include "base/basictypes.h"
#include "base/callback.h"
+#include "base/callback_list.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/safe_browsing/database_manager.h"
#include "chrome/browser/safe_browsing/ui_manager.h"
#include "url/gurl.h"
@@ -33,8 +35,9 @@ class X509Certificate;
} // namespace net
namespace safe_browsing {
-class DownloadFeedbackService;
class BinaryFeatureExtractor;
+class ClientDownloadRequest;
+class DownloadFeedbackService;
// This class provides an asynchronous API to check whether a particular
// client download is malicious or not.
@@ -52,6 +55,22 @@ class DownloadProtectionService {
// Callback type which is invoked once the download request is done.
typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback;
+ // A type of callback run on the main thread when a ClientDownloadRequest has
+ // been formed for a download, or when one has not been formed for a supported
+ // download.
+ typedef base::Callback<void(content::DownloadItem*,
+ const ClientDownloadRequest*)>
+ ClientDownloadRequestCallback;
+
+ // A list of ClientDownloadRequest callbacks.
+ typedef base::CallbackList<void(content::DownloadItem*,
+ const ClientDownloadRequest*)>
+ ClientDownloadRequestCallbackList;
+
+ // A subscription to a registered ClientDownloadRequest callback.
+ typedef scoped_ptr<ClientDownloadRequestCallbackList::Subscription>
+ ClientDownloadRequestSubscription;
+
// Creates a download service. The service is initially disabled. You need
// to call SetEnabled() to start it. |sb_service| owns this object; we
// keep a reference to |request_context_getter|.
@@ -107,6 +126,11 @@ class DownloadProtectionService {
return feedback_service_.get();
}
+ // Registers a callback that will be run when a ClientDownloadRequest has
+ // been formed.
+ ClientDownloadRequestSubscription RegisterClientDownloadRequestCallback(
+ const ClientDownloadRequestCallback& callback);
+
protected:
// Enum to keep track why a particular download verdict was chosen.
// This is used to keep some stats around.
@@ -198,6 +222,10 @@ class DownloadProtectionService {
scoped_ptr<DownloadFeedbackService> feedback_service_;
+ // A list of callbacks to be run on the main thread when a
+ // ClientDownloadRequest has been formed.
+ ClientDownloadRequestCallbackList client_download_request_callbacks_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService);
};
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698