| 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_stats.h" | 8 #include "chrome/browser/download/download_stats.h" |
| 9 #include "content/public/browser/resource_controller.h" | 9 #include "content/public/browser/resource_controller.h" |
| 10 | 10 |
| 11 DownloadResourceThrottle::DownloadResourceThrottle( | 11 DownloadResourceThrottle::DownloadResourceThrottle( |
| 12 DownloadRequestLimiter* limiter, | 12 DownloadRequestLimiter* limiter, |
| 13 int render_process_id, | 13 int render_process_id, |
| 14 int render_view_id, | 14 int render_view_id, |
| 15 int request_id, | 15 const GURL& url, |
| 16 const std::string& request_method) | 16 const std::string& request_method) |
| 17 : querying_limiter_(true), | 17 : querying_limiter_(true), |
| 18 request_allowed_(false), | 18 request_allowed_(false), |
| 19 request_deferred_(false) { | 19 request_deferred_(false) { |
| 20 limiter->CanDownloadOnIOThread( | 20 limiter->CanDownloadOnIOThread( |
| 21 render_process_id, | 21 render_process_id, |
| 22 render_view_id, | 22 render_view_id, |
| 23 request_id, | 23 url, |
| 24 request_method, | 24 request_method, |
| 25 base::Bind(&DownloadResourceThrottle::ContinueDownload, | 25 base::Bind(&DownloadResourceThrottle::ContinueDownload, |
| 26 AsWeakPtr())); | 26 AsWeakPtr())); |
| 27 } | 27 } |
| 28 | 28 |
| 29 DownloadResourceThrottle::~DownloadResourceThrottle() { | 29 DownloadResourceThrottle::~DownloadResourceThrottle() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 void DownloadResourceThrottle::WillStartRequest(bool* defer) { | 32 void DownloadResourceThrottle::WillStartRequest(bool* defer) { |
| 33 WillDownload(defer); | 33 WillDownload(defer); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 if (request_deferred_) { | 75 if (request_deferred_) { |
| 76 request_deferred_ = false; | 76 request_deferred_ = false; |
| 77 if (allow) { | 77 if (allow) { |
| 78 controller()->Resume(); | 78 controller()->Resume(); |
| 79 } else { | 79 } else { |
| 80 controller()->Cancel(); | 80 controller()->Cancel(); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| OLD | NEW |