OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_item.h" | 5 #include "chrome/browser/download/download_item.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 145 } |
146 | 146 |
147 // Constructing for a regular download: | 147 // Constructing for a regular download: |
148 DownloadItem::DownloadItem(DownloadManager* download_manager, | 148 DownloadItem::DownloadItem(DownloadManager* download_manager, |
149 const DownloadCreateInfo& info, | 149 const DownloadCreateInfo& info, |
150 bool is_otr) | 150 bool is_otr) |
151 : state_info_(info.original_name, info.save_info.file_path, | 151 : state_info_(info.original_name, info.save_info.file_path, |
152 info.has_user_gesture, info.prompt_user_for_save_location, | 152 info.has_user_gesture, info.prompt_user_for_save_location, |
153 info.path_uniquifier, false, false, | 153 info.path_uniquifier, false, false, |
154 info.is_extension_install), | 154 info.is_extension_install), |
155 process_handle_(info.process_handle), | 155 request_handle_(info.request_handle), |
156 download_id_(info.download_id), | 156 download_id_(info.download_id), |
157 full_path_(info.path), | 157 full_path_(info.path), |
158 url_chain_(info.url_chain), | 158 url_chain_(info.url_chain), |
159 referrer_url_(info.referrer_url), | 159 referrer_url_(info.referrer_url), |
160 content_disposition_(info.content_disposition), | 160 content_disposition_(info.content_disposition), |
161 mime_type_(info.mime_type), | 161 mime_type_(info.mime_type), |
162 original_mime_type_(info.original_mime_type), | 162 original_mime_type_(info.original_mime_type), |
163 referrer_charset_(info.referrer_charset), | 163 referrer_charset_(info.referrer_charset), |
164 total_bytes_(info.total_bytes), | 164 total_bytes_(info.total_bytes), |
165 received_bytes_(0), | 165 received_bytes_(0), |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 void DownloadItem::Rename(const FilePath& full_path) { | 451 void DownloadItem::Rename(const FilePath& full_path) { |
452 VLOG(20) << __FUNCTION__ << "()" | 452 VLOG(20) << __FUNCTION__ << "()" |
453 << " full_path = \"" << full_path.value() << "\"" | 453 << " full_path = \"" << full_path.value() << "\"" |
454 << " " << DebugString(true); | 454 << " " << DebugString(true); |
455 DCHECK(!full_path.empty()); | 455 DCHECK(!full_path.empty()); |
456 full_path_ = full_path; | 456 full_path_ = full_path; |
457 } | 457 } |
458 | 458 |
459 void DownloadItem::TogglePause() { | 459 void DownloadItem::TogglePause() { |
460 DCHECK(IsInProgress()); | 460 DCHECK(IsInProgress()); |
461 download_manager_->PauseDownload(download_id_, !is_paused_); | 461 if (is_paused_) |
| 462 request_handle_.ResumeRequest(); |
| 463 else |
| 464 request_handle_.PauseRequest(); |
462 is_paused_ = !is_paused_; | 465 is_paused_ = !is_paused_; |
463 UpdateObservers(); | 466 UpdateObservers(); |
464 } | 467 } |
465 | 468 |
466 void DownloadItem::OnDownloadCompleting(DownloadFileManager* file_manager) { | 469 void DownloadItem::OnDownloadCompleting(DownloadFileManager* file_manager) { |
467 VLOG(20) << __FUNCTION__ << "()" | 470 VLOG(20) << __FUNCTION__ << "()" |
468 << " needs rename = " << NeedsRename() | 471 << " needs rename = " << NeedsRename() |
469 << " " << DebugString(true); | 472 << " " << DebugString(true); |
470 DCHECK_NE(DANGEROUS, safety_state()); | 473 DCHECK_NE(DANGEROUS, safety_state()); |
471 DCHECK(file_manager); | 474 DCHECK(file_manager); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 state_info_.target_name.value().c_str(), | 673 state_info_.target_name.value().c_str(), |
671 full_path().value().c_str()); | 674 full_path().value().c_str()); |
672 } else { | 675 } else { |
673 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); | 676 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); |
674 } | 677 } |
675 | 678 |
676 description += " }"; | 679 description += " }"; |
677 | 680 |
678 return description; | 681 return description; |
679 } | 682 } |
OLD | NEW |