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

Side by Side Diff: content/browser/download/save_package.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, 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 | 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/save_package.h" 5 #include "content/browser/download/save_package.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/i18n/file_util_icu.h" 12 #include "base/i18n/file_util_icu.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/pickle.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "base/string_piece.h" 17 #include "base/string_piece.h"
17 #include "base/string_split.h" 18 #include "base/string_split.h"
18 #include "base/sys_string_conversions.h" 19 #include "base/sys_string_conversions.h"
19 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
20 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
21 #include "content/browser/browser_context.h" 22 #include "content/browser/browser_context.h"
22 #include "content/browser/download/download_file_manager.h" 23 #include "content/browser/download/download_file_manager.h"
23 #include "content/browser/download/download_item.h" 24 #include "content/browser/download/download_item.h"
24 #include "content/browser/download/download_manager.h" 25 #include "content/browser/download/download_manager.h"
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 // Let SaveItem set end state. 700 // Let SaveItem set end state.
700 save_item->Finish(size, is_success); 701 save_item->Finish(size, is_success);
701 // Remove the associated save id and SavePackage. 702 // Remove the associated save id and SavePackage.
702 file_manager_->RemoveSaveFile(save_id, save_item->url(), this); 703 file_manager_->RemoveSaveFile(save_id, save_item->url(), this);
703 704
704 PutInProgressItemToSavedMap(save_item); 705 PutInProgressItemToSavedMap(save_item);
705 706
706 // Inform the DownloadItem to update UI. 707 // Inform the DownloadItem to update UI.
707 // We use the received bytes as number of saved files. 708 // We use the received bytes as number of saved files.
708 if (download_) 709 if (download_)
709 download_->Update(completed_count()); 710 download_->Update(completed_count(), Pickle());
710 711
711 if (save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM && 712 if (save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM &&
712 save_item->url() == page_url_ && !save_item->received_bytes()) { 713 save_item->url() == page_url_ && !save_item->received_bytes()) {
713 // If size of main HTML page is 0, treat it as disk error. 714 // If size of main HTML page is 0, treat it as disk error.
714 Cancel(false); 715 Cancel(false);
715 return; 716 return;
716 } 717 }
717 718
718 if (canceled()) { 719 if (canceled()) {
719 DCHECK(finished_); 720 DCHECK(finished_);
(...skipping 21 matching lines...) Expand all
741 } 742 }
742 SaveItem* save_item = it->second; 743 SaveItem* save_item = it->second;
743 744
744 save_item->Finish(0, false); 745 save_item->Finish(0, false);
745 746
746 PutInProgressItemToSavedMap(save_item); 747 PutInProgressItemToSavedMap(save_item);
747 748
748 // Inform the DownloadItem to update UI. 749 // Inform the DownloadItem to update UI.
749 // We use the received bytes as number of saved files. 750 // We use the received bytes as number of saved files.
750 if (download_) 751 if (download_)
751 download_->Update(completed_count()); 752 download_->Update(completed_count(), Pickle());
752 753
753 if (save_type_ == SAVE_AS_ONLY_HTML || 754 if (save_type_ == SAVE_AS_ONLY_HTML ||
754 save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM) { 755 save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM) {
755 // We got error when saving page. Treat it as disk error. 756 // We got error when saving page. Treat it as disk error.
756 Cancel(true); 757 Cancel(true);
757 } 758 }
758 759
759 if (canceled()) { 760 if (canceled()) {
760 DCHECK(finished_); 761 DCHECK(finished_);
761 return; 762 return;
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 StopObservation(); 1282 StopObservation();
1282 } 1283 }
1283 1284
1284 void SavePackage::FinalizeDownloadEntry() { 1285 void SavePackage::FinalizeDownloadEntry() {
1285 DCHECK(download_); 1286 DCHECK(download_);
1286 DCHECK(download_manager_); 1287 DCHECK(download_manager_);
1287 1288
1288 download_manager_->SavePageDownloadFinished(download_); 1289 download_manager_->SavePageDownloadFinished(download_);
1289 StopObservation(); 1290 StopObservation();
1290 } 1291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698