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

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

Issue 722953002: downloads: add the ability to undo download removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheck Created 6 years, 1 month 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
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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 BrowserThread::PostTaskAndReplyWithResult( 334 BrowserThread::PostTaskAndReplyWithResult(
335 BrowserThread::FILE, 335 BrowserThread::FILE,
336 FROM_HERE, 336 FROM_HERE,
337 base::Bind(&DownloadFileDetach, base::Passed(&download_file_)), 337 base::Bind(&DownloadFileDetach, base::Passed(&download_file_)),
338 callback); 338 callback);
339 } else { 339 } else {
340 callback.Run(current_path_); 340 callback.Run(current_path_);
341 } 341 }
342 current_path_.clear(); 342 current_path_.clear();
343 Remove(); 343 Remove();
344 // We have now been deleted.
benjhayden 2014/11/21 00:50:00 I found these comments helpful. Why remove them?
Dan Beam 2014/11/21 05:32:21 because (with this change) they're no longer corre
345 } 344 }
346 345
347 void DownloadItemImpl::Pause() { 346 void DownloadItemImpl::Pause() {
348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
349 348
350 // Ignore irrelevant states. 349 // Ignore irrelevant states.
351 if (state_ != IN_PROGRESS_INTERNAL || is_paused_) 350 if (state_ != IN_PROGRESS_INTERNAL || is_paused_)
352 return; 351 return;
353 352
354 request_handle_->PauseRequest(); 353 request_handle_->PauseRequest();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 void DownloadItemImpl::Remove() { 435 void DownloadItemImpl::Remove() {
437 VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true); 436 VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true);
438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
439 438
440 delegate_->AssertStateConsistent(this); 439 delegate_->AssertStateConsistent(this);
441 Cancel(true); 440 Cancel(true);
442 delegate_->AssertStateConsistent(this); 441 delegate_->AssertStateConsistent(this);
443 442
444 NotifyRemoved(); 443 NotifyRemoved();
445 delegate_->DownloadRemoved(this); 444 delegate_->DownloadRemoved(this);
446 // We have now been deleted.
447 } 445 }
448 446
449 void DownloadItemImpl::OpenDownload() { 447 void DownloadItemImpl::OpenDownload() {
450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
451 449
452 if (!IsDone()) { 450 if (!IsDone()) {
453 // We don't honor the open_when_complete_ flag for temporary 451 // We don't honor the open_when_complete_ flag for temporary
454 // downloads. Don't set it because it shows up in the UI. 452 // downloads. Don't set it because it shows up in the UI.
455 if (!IsTemporary()) 453 if (!IsTemporary())
456 open_when_complete_ = !open_when_complete_; 454 open_when_complete_ = !open_when_complete_;
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 case RESUME_MODE_USER_CONTINUE: 1801 case RESUME_MODE_USER_CONTINUE:
1804 return "USER_CONTINUE"; 1802 return "USER_CONTINUE";
1805 case RESUME_MODE_USER_RESTART: 1803 case RESUME_MODE_USER_RESTART:
1806 return "USER_RESTART"; 1804 return "USER_RESTART";
1807 } 1805 }
1808 NOTREACHED() << "Unknown resume mode " << mode; 1806 NOTREACHED() << "Unknown resume mode " << mode;
1809 return "unknown"; 1807 return "unknown";
1810 } 1808 }
1811 1809
1812 } // namespace content 1810 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698