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

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

Issue 7749013: Made the cancel from CancelDownloadOnRename go through the full cancel path, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed error in tests not bailing on select file. Created 9 years, 4 months 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 | Annotate | Revision Log
OLDNEW
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 "content/browser/download/download_item.h" 5 #include "content/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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // Small downloads might be complete before this method has 360 // Small downloads might be complete before this method has
361 // a chance to run. 361 // a chance to run.
362 return; 362 return;
363 } 363 }
364 364
365 download_stats::RecordDownloadCount(download_stats::CANCELLED_COUNT); 365 download_stats::RecordDownloadCount(download_stats::CANCELLED_COUNT);
366 366
367 TransitionTo(CANCELLED); 367 TransitionTo(CANCELLED);
368 StopProgressTimer(); 368 StopProgressTimer();
369 if (update_history) 369 if (update_history)
370 download_manager_->DownloadCancelled(download_id_); 370 download_manager_->DownloadCancelledInternal(this);
371 } 371 }
372 372
373 void DownloadItem::MarkAsComplete() { 373 void DownloadItem::MarkAsComplete() {
374 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 374 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
375 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 375 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
376 376
377 DCHECK(all_data_saved_); 377 DCHECK(all_data_saved_);
378 TransitionTo(COMPLETE); 378 TransitionTo(COMPLETE);
379 } 379 }
380 380
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 return name; 696 return name;
697 } 697 }
698 return state_info_.target_name; 698 return state_info_.target_name;
699 } 699 }
700 700
701 FilePath DownloadItem::GetUserVerifiedFilePath() const { 701 FilePath DownloadItem::GetUserVerifiedFilePath() const {
702 return (safety_state_ == DownloadItem::SAFE) ? 702 return (safety_state_ == DownloadItem::SAFE) ?
703 GetTargetFilePath() : full_path_; 703 GetTargetFilePath() : full_path_;
704 } 704 }
705 705
706 void DownloadItem::OffThreadCancel(DownloadFileManager* file_manager) {
707 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
708 request_handle_.CancelRequest();
709
710 BrowserThread::PostTask(
711 BrowserThread::FILE, FROM_HERE,
712 NewRunnableMethod(
713 file_manager, &DownloadFileManager::CancelDownload, download_id_));
714 }
715
706 void DownloadItem::Init(bool active) { 716 void DownloadItem::Init(bool active) {
707 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 717 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
708 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 718 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
709 719
710 UpdateTarget(); 720 UpdateTarget();
711 if (active) { 721 if (active) {
712 StartProgressTimer(); 722 StartProgressTimer();
713 download_stats::RecordDownloadCount(download_stats::START_COUNT); 723 download_stats::RecordDownloadCount(download_stats::START_COUNT);
714 } 724 }
715 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); 725 VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 state_info_.target_name.value().c_str(), 795 state_info_.target_name.value().c_str(),
786 full_path().value().c_str()); 796 full_path().value().c_str());
787 } else { 797 } else {
788 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 798 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
789 } 799 }
790 800
791 description += " }"; 801 description += " }";
792 802
793 return description; 803 return description;
794 } 804 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698