Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/download/download_resource_throttle.h" | 5 #include "chrome/browser/download/download_resource_throttle.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/download/download_util.h" | |
| 8 #include "content/public/browser/resource_throttle_controller.h" | 9 #include "content/public/browser/resource_throttle_controller.h" |
| 9 | 10 |
| 10 DownloadResourceThrottle::DownloadResourceThrottle( | 11 DownloadResourceThrottle::DownloadResourceThrottle( |
| 11 DownloadRequestLimiter* limiter, | 12 DownloadRequestLimiter* limiter, |
| 12 int render_process_id, | 13 int render_process_id, |
| 13 int render_view_id, | 14 int render_view_id, |
| 14 int request_id) | 15 int request_id) |
| 15 : request_allowed_(false), | 16 : request_allowed_(false), |
| 16 request_deferred_(false) { | 17 request_deferred_(false) { |
| 17 limiter->CanDownloadOnIOThread( | 18 limiter->CanDownloadOnIOThread( |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 33 bool* defer) { | 34 bool* defer) { |
| 34 *defer = request_deferred_ = !request_allowed_; | 35 *defer = request_deferred_ = !request_allowed_; |
| 35 } | 36 } |
| 36 | 37 |
| 37 void DownloadResourceThrottle::WillReadRequest(bool* defer) { | 38 void DownloadResourceThrottle::WillReadRequest(bool* defer) { |
| 38 *defer = request_deferred_ = !request_allowed_; | 39 *defer = request_deferred_ = !request_allowed_; |
| 39 } | 40 } |
| 40 | 41 |
| 41 void DownloadResourceThrottle::ContinueDownload(bool allow) { | 42 void DownloadResourceThrottle::ContinueDownload(bool allow) { |
| 42 request_allowed_ = allow; | 43 request_allowed_ = allow; |
| 44 if (allow) { | |
| 45 download_util::RecordDownloadSource( | |
|
darin (slow to review)
2012/02/10 23:47:28
nit: indentation
You are counting on the fact tha
Randy Smith (Not in Mondays)
2012/02/12 19:19:00
Done.
| |
| 46 download_util::INITIATED_BY_NAVIGATION); | |
| 47 } else { | |
| 48 download_util::RecordDownloadCount(download_util::BLOCKED_BY_THROTTLING); | |
| 49 } | |
| 43 | 50 |
| 44 if (request_deferred_) { | 51 if (request_deferred_) { |
| 45 if (allow) { | 52 if (allow) { |
| 46 controller()->Resume(); | 53 controller()->Resume(); |
| 47 } else { | 54 } else { |
| 48 controller()->Cancel(); | 55 controller()->Cancel(); |
| 49 } | 56 } |
| 50 } | 57 } |
| 51 } | 58 } |
| OLD | NEW |