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

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

Issue 15881012: Implement safebrowsing download feedback service, enabled for dev & canary only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "chrome/browser/safe_browsing/two_phase_uploader.h"
15
16 namespace content {
17 class DownloadItem;
18 }
19
20 namespace safe_browsing {
21
22 class DownloadFeedbackFactory;
23
24 // Handles the uploading of a single downloaded binary to the safebrowsing
25 // download feedback service.
26 class DownloadFeedback : public base::NonThreadSafe {
27 public:
28 // Takes ownership of the file pointed to be |file_path|, it will be deleted
29 // when the DownloadFeedback is destructed.
30 static DownloadFeedback* Create(
31 net::URLRequestContextGetter* request_context_getter,
32 base::TaskRunner* file_task_runner,
33 const base::FilePath& file_path,
34 const std::string& ping_request,
35 const std::string& ping_response);
36
37 // The largest file size we support uploading.
38 // Note: changing this will affect the max size of
39 // SBDownloadFeedback.SizeSuccess and SizeFailure histograms.
40 static const int64 kMaxUploadSize;
41
42 virtual ~DownloadFeedback() {}
43
44 // Makes the passed |factory| the factory used to instantiate
45 // a DownloadFeedback. Useful for tests.
46 static void RegisterFactory(DownloadFeedbackFactory* factory) {
47 factory_ = factory;
48 }
49
50 // Start uploading the file to the download feedback service.
51 // |finish_callback| will be called when the upload completes or fails, but is
52 // not called if the upload is cancelled by deleting the DownloadFeedback
53 // while the upload is in progress.
54 virtual void Start(const base::Closure& finish_callback) = 0;
55
56 virtual const std::string& GetPingRequestForTesting() const = 0;
57 virtual const std::string& GetPingResponseForTesting() const = 0;
58
59 private:
60 // The factory that controls the creation of DownloadFeedback objects.
61 // This is used by tests.
62 static DownloadFeedbackFactory* factory_;
63 };
64
65 class DownloadFeedbackFactory {
66 public:
67 virtual ~DownloadFeedbackFactory() {}
68
69 virtual DownloadFeedback* CreateDownloadFeedback(
70 net::URLRequestContextGetter* request_context_getter,
71 base::TaskRunner* file_task_runner,
72 const base::FilePath& file_path,
73 const std::string& ping_request,
74 const std::string& ping_response) = 0;
75 };
76
77 } // namespace safe_browsing
78
79 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698