| 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 "content/browser/download/download_request_core.h" | 5 #include "content/browser/download/download_request_core.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 for (const auto& header : params->request_headers()) | 174 for (const auto& header : params->request_headers()) |
| 175 request->SetExtraRequestHeaderByName(header.first, header.second, | 175 request->SetExtraRequestHeaderByName(header.first, header.second, |
| 176 false /*overwrite*/); | 176 false /*overwrite*/); |
| 177 | 177 |
| 178 DownloadRequestData::Attach(request.get(), params, download_id); | 178 DownloadRequestData::Attach(request.get(), params, download_id); |
| 179 return request; | 179 return request; |
| 180 } | 180 } |
| 181 | 181 |
| 182 DownloadRequestCore::DownloadRequestCore(net::URLRequest* request, | 182 DownloadRequestCore::DownloadRequestCore(net::URLRequest* request, |
| 183 Delegate* delegate) | 183 Delegate* delegate, |
| 184 bool is_parallel_request) |
| 184 : delegate_(delegate), | 185 : delegate_(delegate), |
| 185 request_(request), | 186 request_(request), |
| 186 download_id_(DownloadItem::kInvalidId), | 187 download_id_(DownloadItem::kInvalidId), |
| 187 transient_(false), | 188 transient_(false), |
| 188 bytes_read_(0), | 189 bytes_read_(0), |
| 189 pause_count_(0), | 190 pause_count_(0), |
| 190 was_deferred_(false), | 191 was_deferred_(false), |
| 191 is_partial_request_(false), | 192 is_partial_request_(false), |
| 192 started_(false), | 193 started_(false), |
| 193 abort_reason_(DOWNLOAD_INTERRUPT_REASON_NONE) { | 194 abort_reason_(DOWNLOAD_INTERRUPT_REASON_NONE) { |
| 194 DCHECK(request_); | 195 DCHECK(request_); |
| 195 DCHECK(delegate_); | 196 DCHECK(delegate_); |
| 196 RecordDownloadCount(UNTHROTTLED_COUNT); | 197 if (!is_parallel_request) |
| 198 RecordDownloadCount(UNTHROTTLED_COUNT); |
| 197 power_save_blocker_.reset(new device::PowerSaveBlocker( | 199 power_save_blocker_.reset(new device::PowerSaveBlocker( |
| 198 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 200 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 199 device::PowerSaveBlocker::kReasonOther, "Download in progress", | 201 device::PowerSaveBlocker::kReasonOther, "Download in progress", |
| 200 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 202 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 201 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); | 203 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); |
| 202 DownloadRequestData* request_data = DownloadRequestData::Get(request_); | 204 DownloadRequestData* request_data = DownloadRequestData::Get(request_); |
| 203 if (request_data) { | 205 if (request_data) { |
| 204 save_info_ = request_data->TakeSaveInfo(); | 206 save_info_ = request_data->TakeSaveInfo(); |
| 205 download_id_ = request_data->download_id(); | 207 download_id_ = request_data->download_id(); |
| 206 transient_ = request_data->is_transient(); | 208 transient_ = request_data->is_transient(); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 // old servers that didn't implement "If-Match" and must be ignored when | 678 // old servers that didn't implement "If-Match" and must be ignored when |
| 677 // "If-Match" presents. | 679 // "If-Match" presents. |
| 678 if (has_last_modified) { | 680 if (has_last_modified) { |
| 679 request->SetExtraRequestHeaderByName( | 681 request->SetExtraRequestHeaderByName( |
| 680 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), | 682 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), |
| 681 true); | 683 true); |
| 682 } | 684 } |
| 683 } | 685 } |
| 684 | 686 |
| 685 } // namespace content | 687 } // namespace content |
| OLD | NEW |