Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 795353002: downloads: prevent "Clear all" from removing in progress downloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: todo Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // File method ordering: Methods in this file are in the same order as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 file_externally_removed_(false), 155 file_externally_removed_(false),
156 auto_opened_(false), 156 auto_opened_(false),
157 is_temporary_(false), 157 is_temporary_(false),
158 all_data_saved_(state == COMPLETE), 158 all_data_saved_(state == COMPLETE),
159 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 159 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
160 opened_(opened), 160 opened_(opened),
161 delegate_delayed_complete_(false), 161 delegate_delayed_complete_(false),
162 bound_net_log_(bound_net_log), 162 bound_net_log_(bound_net_log),
163 weak_ptr_factory_(this) { 163 weak_ptr_factory_(this) {
164 delegate_->Attach(); 164 delegate_->Attach();
165 DCHECK_NE(IN_PROGRESS_INTERNAL, state_); 165 DCHECK_NE(IN_PROGRESS_INTERNAL, state_);
Dan Beam 2014/12/12 04:29:30 hit this in the tests, rewrote with gmock, ptal
166 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT); 166 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT);
167 } 167 }
168 168
169 // Constructing for a regular download: 169 // Constructing for a regular download:
170 DownloadItemImpl::DownloadItemImpl( 170 DownloadItemImpl::DownloadItemImpl(
171 DownloadItemImplDelegate* delegate, 171 DownloadItemImplDelegate* delegate,
172 uint32 download_id, 172 uint32 download_id,
173 const DownloadCreateInfo& info, 173 const DownloadCreateInfo& info,
174 const net::BoundNetLog& bound_net_log) 174 const net::BoundNetLog& bound_net_log)
175 : is_save_package_download_(false), 175 : is_save_package_download_(false),
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 RecordDownloadCount(CANCELLED_COUNT); 408 RecordDownloadCount(CANCELLED_COUNT);
409 409
410 // TODO(rdsmith/benjhayden): Remove condition as part of 410 // TODO(rdsmith/benjhayden): Remove condition as part of
411 // |SavePackage| integration. 411 // |SavePackage| integration.
412 // |download_file_| can be NULL if Interrupt() is called after the 412 // |download_file_| can be NULL if Interrupt() is called after the
413 // download file has been released. 413 // download file has been released.
414 if (!is_save_package_download_ && download_file_) 414 if (!is_save_package_download_ && download_file_)
415 ReleaseDownloadFile(true); 415 ReleaseDownloadFile(true);
416 416
417 if (state_ == IN_PROGRESS_INTERNAL) { 417 // |request_handle_| may be NULL during tests. TODO(dbeam): inject a fake one
418 // instead?
419 if (state_ == IN_PROGRESS_INTERNAL && request_handle_) {
418 // Cancel the originating URL request unless it's already been cancelled 420 // Cancel the originating URL request unless it's already been cancelled
419 // by interrupt. 421 // by interrupt.
420 request_handle_->CancelRequest(); 422 request_handle_->CancelRequest();
421 } 423 }
422 424
423 // Remove the intermediate file if we are cancelling an interrupted download. 425 // Remove the intermediate file if we are cancelling an interrupted download.
424 // Continuable interruptions leave the intermediate file around. 426 // Continuable interruptions leave the intermediate file around.
425 if ((state_ == INTERRUPTED_INTERNAL || state_ == RESUMING_INTERNAL) && 427 if ((state_ == INTERRUPTED_INTERNAL || state_ == RESUMING_INTERNAL) &&
426 !current_path_.empty()) { 428 !current_path_.empty()) {
427 BrowserThread::PostTask( 429 BrowserThread::PostTask(
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 case RESUME_MODE_USER_CONTINUE: 1806 case RESUME_MODE_USER_CONTINUE:
1805 return "USER_CONTINUE"; 1807 return "USER_CONTINUE";
1806 case RESUME_MODE_USER_RESTART: 1808 case RESUME_MODE_USER_RESTART:
1807 return "USER_RESTART"; 1809 return "USER_RESTART";
1808 } 1810 }
1809 NOTREACHED() << "Unknown resume mode " << mode; 1811 NOTREACHED() << "Unknown resume mode " << mode;
1810 return "unknown"; 1812 return "unknown";
1811 } 1813 }
1812 1814
1813 } // namespace content 1815 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698