| 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.h" | 5 #include "chrome/browser/safe_browsing/download_feedback.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util_proxy.h" | 8 #include "base/files/file_util_proxy.h" |
| 9 #include "base/macros.h" |
| 9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 10 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
| 11 #include "chrome/common/safe_browsing/csd.pb.h" | 12 #include "chrome/common/safe_browsing/csd.pb.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 | 14 |
| 14 namespace safe_browsing { | 15 namespace safe_browsing { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // This enum is used by histograms. Do not change the ordering or remove items. | 19 // This enum is used by histograms. Do not change the ordering or remove items. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 TwoPhaseUploader::State state, | 58 TwoPhaseUploader::State state, |
| 58 int net_error, | 59 int net_error, |
| 59 int response_code, | 60 int response_code, |
| 60 const std::string& response); | 61 const std::string& response); |
| 61 | 62 |
| 62 void RecordUploadResult(UploadResultType result); | 63 void RecordUploadResult(UploadResultType result); |
| 63 | 64 |
| 64 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 65 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 65 scoped_refptr<base::TaskRunner> file_task_runner_; | 66 scoped_refptr<base::TaskRunner> file_task_runner_; |
| 66 const base::FilePath file_path_; | 67 const base::FilePath file_path_; |
| 67 int64 file_size_; | 68 int64_t file_size_; |
| 68 | 69 |
| 69 // The safebrowsing request and response of checking that this binary is | 70 // The safebrowsing request and response of checking that this binary is |
| 70 // unsafe. | 71 // unsafe. |
| 71 std::string ping_request_; | 72 std::string ping_request_; |
| 72 std::string ping_response_; | 73 std::string ping_response_; |
| 73 | 74 |
| 74 scoped_ptr<TwoPhaseUploader> uploader_; | 75 scoped_ptr<TwoPhaseUploader> uploader_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackImpl); | 77 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackImpl); |
| 77 }; | 78 }; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 else | 186 else |
| 186 UMA_HISTOGRAM_CUSTOM_COUNTS( | 187 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 187 "SBDownloadFeedback.SizeFailure", file_size_, 1, kMaxUploadSize, 50); | 188 "SBDownloadFeedback.SizeFailure", file_size_, 1, kMaxUploadSize, 50); |
| 188 UMA_HISTOGRAM_ENUMERATION( | 189 UMA_HISTOGRAM_ENUMERATION( |
| 189 "SBDownloadFeedback.UploadResult", result, UPLOAD_RESULT_MAX); | 190 "SBDownloadFeedback.UploadResult", result, UPLOAD_RESULT_MAX); |
| 190 } | 191 } |
| 191 | 192 |
| 192 } // namespace | 193 } // namespace |
| 193 | 194 |
| 194 // static | 195 // static |
| 195 const int64 DownloadFeedback::kMaxUploadSize = 50 * 1024 * 1024; | 196 const int64_t DownloadFeedback::kMaxUploadSize = 50 * 1024 * 1024; |
| 196 | 197 |
| 197 // static | 198 // static |
| 198 const char DownloadFeedback::kSbFeedbackURL[] = | 199 const char DownloadFeedback::kSbFeedbackURL[] = |
| 199 "https://safebrowsing.google.com/safebrowsing/uploads/chrome"; | 200 "https://safebrowsing.google.com/safebrowsing/uploads/chrome"; |
| 200 | 201 |
| 201 // static | 202 // static |
| 202 DownloadFeedbackFactory* DownloadFeedback::factory_ = NULL; | 203 DownloadFeedbackFactory* DownloadFeedback::factory_ = NULL; |
| 203 | 204 |
| 204 // static | 205 // static |
| 205 DownloadFeedback* DownloadFeedback::Create( | 206 DownloadFeedback* DownloadFeedback::Create( |
| 206 net::URLRequestContextGetter* request_context_getter, | 207 net::URLRequestContextGetter* request_context_getter, |
| 207 base::TaskRunner* file_task_runner, | 208 base::TaskRunner* file_task_runner, |
| 208 const base::FilePath& file_path, | 209 const base::FilePath& file_path, |
| 209 const std::string& ping_request, | 210 const std::string& ping_request, |
| 210 const std::string& ping_response) { | 211 const std::string& ping_response) { |
| 211 if (!DownloadFeedback::factory_) | 212 if (!DownloadFeedback::factory_) |
| 212 return new DownloadFeedbackImpl( | 213 return new DownloadFeedbackImpl( |
| 213 request_context_getter, file_task_runner, file_path, ping_request, | 214 request_context_getter, file_task_runner, file_path, ping_request, |
| 214 ping_response); | 215 ping_response); |
| 215 return DownloadFeedback::factory_->CreateDownloadFeedback( | 216 return DownloadFeedback::factory_->CreateDownloadFeedback( |
| 216 request_context_getter, file_task_runner, file_path, ping_request, | 217 request_context_getter, file_task_runner, file_path, ping_request, |
| 217 ping_response); | 218 ping_response); |
| 218 } | 219 } |
| 219 | 220 |
| 220 } // namespace safe_browsing | 221 } // namespace safe_browsing |
| 221 | 222 |
| OLD | NEW |