OLD | NEW |
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 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 5 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 84 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
85 } | 85 } |
86 | 86 |
87 DownloadFeedbackService::~DownloadFeedbackService() { | 87 DownloadFeedbackService::~DownloadFeedbackService() { |
88 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 88 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
89 } | 89 } |
90 | 90 |
91 // static | 91 // static |
92 void DownloadFeedbackService::MaybeStorePingsForDownload( | 92 void DownloadFeedbackService::MaybeStorePingsForDownload( |
93 DownloadProtectionService::DownloadCheckResult result, | 93 DownloadProtectionService::DownloadCheckResult result, |
| 94 bool upload_requested, |
94 content::DownloadItem* download, | 95 content::DownloadItem* download, |
95 const std::string& ping, | 96 const std::string& ping, |
96 const std::string& response) { | 97 const std::string& response) { |
97 switch (result) { | 98 // We never upload SAFE files. |
98 case DownloadProtectionService::UNKNOWN: | 99 if (result == DownloadProtectionService::SAFE) |
99 case DownloadProtectionService::SAFE: | 100 return; |
100 case DownloadProtectionService::DANGEROUS: | 101 |
101 return; | 102 UMA_HISTOGRAM_BOOLEAN("SBDownloadFeedback.UploadRequestedByServer", |
102 case DownloadProtectionService::UNCOMMON: | 103 upload_requested); |
103 case DownloadProtectionService::DANGEROUS_HOST: | 104 if (!upload_requested) |
104 case DownloadProtectionService::POTENTIALLY_UNWANTED: | 105 return; |
105 break; // Fall through. | 106 |
106 } | |
107 UMA_HISTOGRAM_COUNTS("SBDownloadFeedback.SizeEligibleKB", | 107 UMA_HISTOGRAM_COUNTS("SBDownloadFeedback.SizeEligibleKB", |
108 download->GetReceivedBytes() / 1024); | 108 download->GetReceivedBytes() / 1024); |
109 if (download->GetReceivedBytes() > DownloadFeedback::kMaxUploadSize) | 109 if (download->GetReceivedBytes() > DownloadFeedback::kMaxUploadSize) |
110 return; | 110 return; |
111 | 111 |
112 DownloadFeedbackPings::CreateForDownload(download, ping, response); | 112 DownloadFeedbackPings::CreateForDownload(download, ping, response); |
113 } | 113 } |
114 | 114 |
115 // static | 115 // static |
116 bool DownloadFeedbackService::IsEnabledForDownload( | 116 bool DownloadFeedbackService::IsEnabledForDownload( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 void DownloadFeedbackService::FeedbackComplete() { | 205 void DownloadFeedbackService::FeedbackComplete() { |
206 DVLOG(1) << __func__; | 206 DVLOG(1) << __func__; |
207 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 207 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
208 DCHECK(!active_feedback_.empty()); | 208 DCHECK(!active_feedback_.empty()); |
209 active_feedback_.pop(); | 209 active_feedback_.pop(); |
210 if (!active_feedback_.empty()) | 210 if (!active_feedback_.empty()) |
211 StartPendingFeedback(); | 211 StartPendingFeedback(); |
212 } | 212 } |
213 | 213 |
214 } // namespace safe_browsing | 214 } // namespace safe_browsing |
OLD | NEW |