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

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

Issue 2439533002: Download Feedback Service should upload all eligible downloads (Closed)
Patch Set: make windows bots happy Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_SERVICE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_SERVICE_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "chrome/browser/download/download_commands.h"
14 #include "chrome/browser/safe_browsing/download_protection_service.h" 15 #include "chrome/browser/safe_browsing/download_protection_service.h"
15 #include "content/public/browser/download_danger_type.h" 16 #include "content/public/browser/download_danger_type.h"
16 17
17 namespace base { 18 namespace base {
18 class TaskRunner; 19 class TaskRunner;
19 } 20 }
20 21
21 namespace content { 22 namespace content {
22 class DownloadItem; 23 class DownloadItem;
23 } 24 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // are present. 57 // are present.
57 static bool GetPingsForDownloadForTesting( 58 static bool GetPingsForDownloadForTesting(
58 const content::DownloadItem& download, 59 const content::DownloadItem& download,
59 std::string* ping, 60 std::string* ping,
60 std::string* response); 61 std::string* response);
61 62
62 // Records histogram for download feedback option shown to user. 63 // Records histogram for download feedback option shown to user.
63 static void RecordEligibleDownloadShown( 64 static void RecordEligibleDownloadShown(
64 content::DownloadDangerType danger_type); 65 content::DownloadDangerType danger_type);
65 66
66 // Begin download feedback for |download|. The |download| will be deleted 67 // Begin download feedback for |download|. Then delete download file if
67 // when this function returns. This must only be called if 68 // |download_command| is DISCARD, or run the KEEP command otherwise.This must
68 // IsEnabledForDownload is true for |download|. 69 // only be called if IsEnabledForDownload is true for |download|.
69 void BeginFeedbackForDownload(content::DownloadItem* download); 70 void BeginFeedbackForDownload(content::DownloadItem* download,
71 DownloadCommands::Command download_command);
70 72
71 private: 73 private:
72 static void BeginFeedbackOrDeleteFile( 74 static void BeginFeedbackOrDeleteFile(
73 const scoped_refptr<base::TaskRunner>& file_task_runner, 75 const scoped_refptr<base::TaskRunner>& file_task_runner,
74 const base::WeakPtr<DownloadFeedbackService>& service, 76 const base::WeakPtr<DownloadFeedbackService>& service,
75 const std::string& ping_request, 77 const std::string& ping_request,
76 const std::string& ping_response, 78 const std::string& ping_response,
77 const base::FilePath& path); 79 const base::FilePath& path);
78 void StartPendingFeedback(); 80 void StartPendingFeedback();
79 void BeginFeedback(const std::string& ping_request, 81 void BeginFeedback(const std::string& ping_request,
80 const std::string& ping_response, 82 const std::string& ping_response,
81 const base::FilePath& path); 83 const base::FilePath& path);
82 void FeedbackComplete(); 84 void FeedbackComplete();
83 85
84 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 86 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
85 scoped_refptr<base::TaskRunner> file_task_runner_; 87 scoped_refptr<base::TaskRunner> file_task_runner_;
86 88
87 // Currently active & pending uploads. The first item is active, remaining 89 // Currently active & pending uploads. The first item is active, remaining
88 // items are pending. 90 // items are pending.
89 std::queue<std::unique_ptr<DownloadFeedback>> active_feedback_; 91 std::queue<std::unique_ptr<DownloadFeedback>> active_feedback_;
90 92
91 base::WeakPtrFactory<DownloadFeedbackService> weak_ptr_factory_; 93 base::WeakPtrFactory<DownloadFeedbackService> weak_ptr_factory_;
92 94
93 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackService); 95 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackService);
94 }; 96 };
95 } // namespace safe_browsing 97 } // namespace safe_browsing
96 98
97 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_SERVICE_H_ 99 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_FEEDBACK_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ntp_snippets/fake_download_item.cc ('k') | chrome/browser/safe_browsing/download_feedback_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698