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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk Created 9 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 | 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_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 void DownloadManagerImpl::OnFileRemovalDetected(int64 db_handle) { 287 void DownloadManagerImpl::OnFileRemovalDetected(int64 db_handle) {
288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
289 DownloadMap::iterator it = history_downloads_.find(db_handle); 289 DownloadMap::iterator it = history_downloads_.find(db_handle);
290 if (it != history_downloads_.end()) { 290 if (it != history_downloads_.end()) {
291 DownloadItem* download_item = it->second; 291 DownloadItem* download_item = it->second;
292 download_item->OnDownloadedFileRemoved(); 292 download_item->OnDownloadedFileRemoved();
293 } 293 }
294 } 294 }
295 295
296 void DownloadManagerImpl::RestartDownload( 296 void DownloadManagerImpl::RestartDownload(int32 download_id) {
297 int32 download_id) {
298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
299 298
300 DownloadItem* download = GetActiveDownloadItem(download_id); 299 DownloadItem* download = GetActiveDownloadItem(download_id);
301 if (!download) 300 if (!download)
302 return; 301 return;
303 302
304 VLOG(20) << __FUNCTION__ << "()" 303 VLOG(20) << __FUNCTION__ << "()"
305 << " download = " << download->DebugString(true); 304 << " download = " << download->DebugString(true);
306 305
307 FilePath suggested_path = download->GetSuggestedPath(); 306 FilePath suggested_path = download->GetSuggestedPath();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 BrowserThread::FILE, FROM_HERE, 413 BrowserThread::FILE, FROM_HERE,
415 base::Bind(&DownloadFileManager::RenameInProgressDownloadFile, 414 base::Bind(&DownloadFileManager::RenameInProgressDownloadFile,
416 file_manager_, download->GetGlobalId(), 415 file_manager_, download->GetGlobalId(),
417 download_path)); 416 download_path));
418 417
419 download->Rename(download_path); 418 download->Rename(download_path);
420 419
421 delegate_->AddItemToPersistentStore(download); 420 delegate_->AddItemToPersistentStore(download);
422 } 421 }
423 422
424 void DownloadManagerImpl::UpdateDownload(int32 download_id, int64 bytes_so_far, 423 void DownloadManagerImpl::UpdateDownload(int32 download_id,
425 int64 bytes_per_sec) { 424 int64 bytes_so_far,
425 int64 bytes_per_sec,
426 std::string hash_state) {
426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
427 DownloadMap::iterator it = active_downloads_.find(download_id); 428 DownloadMap::iterator it = active_downloads_.find(download_id);
428 if (it != active_downloads_.end()) { 429 if (it != active_downloads_.end()) {
429 DownloadItem* download = it->second; 430 DownloadItem* download = it->second;
430 if (download->IsInProgress()) { 431 if (download->IsInProgress()) {
431 download->UpdateProgress(bytes_so_far, bytes_per_sec); 432 download->UpdateProgress(bytes_so_far, bytes_per_sec, hash_state);
432 UpdateDownloadProgress(); // Reflect size updates. 433 UpdateDownloadProgress(); // Reflect size updates.
433 delegate_->UpdateItemInPersistentStore(download); 434 delegate_->UpdateItemInPersistentStore(download);
434 } 435 }
435 } 436 }
436 } 437 }
437 438
438 void DownloadManagerImpl::OnResponseCompleted(int32 download_id, 439 void DownloadManagerImpl::OnResponseCompleted(int32 download_id,
439 int64 size, 440 int64 size,
440 const std::string& hash) { 441 const std::string& hash) {
441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // This function is called from the DownloadItem, so DI state 615 // This function is called from the DownloadItem, so DI state
615 // should already have been updated. 616 // should already have been updated.
616 AssertStateConsistent(download); 617 AssertStateConsistent(download);
617 618
618 if (file_manager_) 619 if (file_manager_)
619 download->OffThreadCancel(file_manager_); 620 download->OffThreadCancel(file_manager_);
620 } 621 }
621 622
622 void DownloadManagerImpl::OnDownloadInterrupted(int32 download_id, 623 void DownloadManagerImpl::OnDownloadInterrupted(int32 download_id,
623 int64 size, 624 int64 size,
625 std::string hash_state,
624 InterruptReason reason) { 626 InterruptReason reason) {
625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 627 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
626 628
627 DownloadItem* download = GetActiveDownload(download_id); 629 DownloadItem* download = GetActiveDownload(download_id);
628 if (!download) 630 if (!download)
629 return; 631 return;
630 632
631 VLOG(20) << __FUNCTION__ << "()" 633 VLOG(20) << __FUNCTION__ << "()"
632 << " reason " << InterruptReasonDebugString(reason) 634 << " reason " << InterruptReasonDebugString(reason)
633 << " at offset " << download->GetReceivedBytes() 635 << " at offset " << download->GetReceivedBytes()
634 << " size = " << size 636 << " size = " << size
635 << " download = " << download->DebugString(true); 637 << " download = " << download->DebugString(true);
636 638
637 RemoveFromActiveList(download); 639 RemoveFromActiveList(download);
638 download->Interrupted(size, reason); 640 download->Interrupted(size, hash_state, reason);
639 download->OffThreadCancel(file_manager_); 641 download->OffThreadCancel(file_manager_);
640 } 642 }
641 643
642 DownloadItem* DownloadManagerImpl::GetActiveDownload(int32 download_id) { 644 DownloadItem* DownloadManagerImpl::GetActiveDownload(int32 download_id) {
643 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 645 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
644 DownloadMap::iterator it = active_downloads_.find(download_id); 646 DownloadMap::iterator it = active_downloads_.find(download_id);
645 if (it == active_downloads_.end()) 647 if (it == active_downloads_.end())
646 return NULL; 648 return NULL;
647 649
648 DownloadItem* download = it->second; 650 DownloadItem* download = it->second;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 763 }
762 764
763 void DownloadManagerImpl::DownloadUrlToFile(const GURL& url, 765 void DownloadManagerImpl::DownloadUrlToFile(const GURL& url,
764 const GURL& referrer, 766 const GURL& referrer,
765 const std::string& referrer_charset, 767 const std::string& referrer_charset,
766 const DownloadSaveInfo& save_info, 768 const DownloadSaveInfo& save_info,
767 TabContents* tab_contents) { 769 TabContents* tab_contents) {
768 DCHECK(tab_contents); 770 DCHECK(tab_contents);
769 ResourceDispatcherHost* resource_dispatcher_host = 771 ResourceDispatcherHost* resource_dispatcher_host =
770 content::GetContentClient()->browser()->GetResourceDispatcherHost(); 772 content::GetContentClient()->browser()->GetResourceDispatcherHost();
773
771 // We send a pointer to content::ResourceContext, instead of the usual 774 // We send a pointer to content::ResourceContext, instead of the usual
772 // reference, so that a copy of the object isn't made. 775 // reference, so that a copy of the object isn't made.
773 // base::Bind can't handle 7 args, so we use URLParams and RenderParams. 776 // base::Bind can't handle 7 args, so we use URLParams and RenderParams.
774 BrowserThread::PostTask( 777 BrowserThread::PostTask(
775 BrowserThread::IO, FROM_HERE, 778 BrowserThread::IO, FROM_HERE,
776 base::Bind(&BeginDownload, 779 base::Bind(&BeginDownload,
777 URLParams(url, referrer), save_info, resource_dispatcher_host, 780 URLParams(url, referrer), save_info, resource_dispatcher_host,
778 RenderParams(tab_contents->GetRenderProcessHost()->GetID(), 781 RenderParams(tab_contents->GetRenderProcessHost()->GetID(),
779 tab_contents->GetRenderViewHost()->routing_id()), 782 tab_contents->GetRenderViewHost()->routing_id()),
780 &tab_contents->browser_context()->GetResourceContext())); 783 &tab_contents->browser_context()->GetResourceContext()));
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 it != history_downloads_.end(); ++it) { 1135 it != history_downloads_.end(); ++it) {
1133 if (it->second->IsComplete() && !it->second->GetOpened()) 1136 if (it->second->IsComplete() && !it->second->GetOpened())
1134 ++num_unopened; 1137 ++num_unopened;
1135 } 1138 }
1136 download_stats::RecordOpensOutstanding(num_unopened); 1139 download_stats::RecordOpensOutstanding(num_unopened);
1137 } 1140 }
1138 1141
1139 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { 1142 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) {
1140 file_manager_ = file_manager; 1143 file_manager_ = file_manager;
1141 } 1144 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_persistent_store_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698