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

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

Issue 10827314: Revert 151351 - Replace the DownloadFileManager with direct ownership (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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) 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 #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/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/string_piece.h" 16 #include "base/string_piece.h"
17 #include "base/string_split.h" 17 #include "base/string_split.h"
18 #include "base/sys_string_conversions.h" 18 #include "base/sys_string_conversions.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "content/browser/download/download_file_manager.h"
21 #include "content/browser/download/download_item_impl.h" 22 #include "content/browser/download/download_item_impl.h"
22 #include "content/browser/download/download_manager_impl.h" 23 #include "content/browser/download/download_manager_impl.h"
23 #include "content/browser/download/download_stats.h" 24 #include "content/browser/download/download_stats.h"
24 #include "content/browser/download/save_file.h" 25 #include "content/browser/download/save_file.h"
25 #include "content/browser/download/save_file_manager.h" 26 #include "content/browser/download/save_file_manager.h"
26 #include "content/browser/download/save_item.h" 27 #include "content/browser/download/save_item.h"
27 #include "content/browser/renderer_host/render_process_host_impl.h" 28 #include "content/browser/renderer_host/render_process_host_impl.h"
28 #include "content/browser/renderer_host/render_view_host_delegate.h" 29 #include "content/browser/renderer_host/render_view_host_delegate.h"
29 #include "content/browser/renderer_host/render_view_host_impl.h" 30 #include "content/browser/renderer_host/render_view_host_impl.h"
30 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 31 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (size <= 0) { 332 if (size <= 0) {
332 Cancel(false); 333 Cancel(false);
333 return; 334 return;
334 } 335 }
335 wrote_to_completed_file_ = true; 336 wrote_to_completed_file_ = true;
336 download_->SetTotalBytes(size); 337 download_->SetTotalBytes(size);
337 download_->UpdateProgress(size, size, DownloadItem::kEmptyFileHash); 338 download_->UpdateProgress(size, size, DownloadItem::kEmptyFileHash);
338 // Must call OnAllDataSaved here in order for 339 // Must call OnAllDataSaved here in order for
339 // GDataDownloadObserver::ShouldUpload() to return true. 340 // GDataDownloadObserver::ShouldUpload() to return true.
340 // ShouldCompleteDownload() may depend on the gdata uploader to finish. 341 // ShouldCompleteDownload() may depend on the gdata uploader to finish.
341 download_->UpdateProgress(size, CurrentSpeed(), ""); 342 download_->OnAllDataSaved(size, DownloadItem::kEmptyFileHash);
342 download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
343 if (!download_manager_->GetDelegate() || 343 if (!download_manager_->GetDelegate() ||
344 download_manager_->GetDelegate()->ShouldCompleteDownload( 344 download_manager_->GetDelegate()->ShouldCompleteDownload(
345 download_, base::Bind(&SavePackage::Finish, this))) { 345 download_, base::Bind(&SavePackage::Finish, this))) {
346 Finish(); 346 Finish();
347 } 347 }
348 } 348 }
349 349
350 // On POSIX, the length of |pure_file_name| + |file_name_ext| is further 350 // On POSIX, the length of |pure_file_name| + |file_name_ext| is further
351 // restricted by NAME_MAX. The maximum allowed path looks like: 351 // restricted by NAME_MAX. The maximum allowed path looks like:
352 // '/path/to/save_dir' + '/' + NAME_MAX. 352 // '/path/to/save_dir' + '/' + NAME_MAX.
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 it != saved_failed_items_.end(); ++it) 735 it != saved_failed_items_.end(); ++it)
736 save_ids.push_back(it->second->save_id()); 736 save_ids.push_back(it->second->save_id());
737 737
738 BrowserThread::PostTask( 738 BrowserThread::PostTask(
739 BrowserThread::FILE, FROM_HERE, 739 BrowserThread::FILE, FROM_HERE,
740 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, 740 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap,
741 file_manager_, 741 file_manager_,
742 save_ids)); 742 save_ids));
743 743
744 if (download_) { 744 if (download_) {
745 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) { 745 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML)
746 download_->UpdateProgress(all_save_items_count_, CurrentSpeed(), ""); 746 download_->OnAllDataSaved(all_save_items_count_,
747 download_->OnAllDataSaved(DownloadItem::kEmptyFileHash); 747 DownloadItem::kEmptyFileHash);
748 }
749 download_->MarkAsComplete(); 748 download_->MarkAsComplete();
750 FinalizeDownloadEntry(); 749 FinalizeDownloadEntry();
751 } 750 }
752 } 751 }
753 752
754 // Called for updating end state. 753 // Called for updating end state.
755 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { 754 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) {
756 // Because we might have canceled this saving job before, 755 // Because we might have canceled this saving job before,
757 // so we might not find corresponding SaveItem. Just ignore it. 756 // so we might not find corresponding SaveItem. Just ignore it.
758 SaveItem* save_item = LookupItemInProcessBySaveId(save_id); 757 SaveItem* save_item = LookupItemInProcessBySaveId(save_id);
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 StopObservation(); 1362 StopObservation();
1364 } 1363 }
1365 1364
1366 void SavePackage::FinalizeDownloadEntry() { 1365 void SavePackage::FinalizeDownloadEntry() {
1367 DCHECK(download_); 1366 DCHECK(download_);
1368 DCHECK(download_manager_); 1367 DCHECK(download_manager_);
1369 1368
1370 download_manager_->SavePageDownloadFinished(download_); 1369 download_manager_->SavePageDownloadFinished(download_);
1371 StopObservation(); 1370 StopObservation();
1372 } 1371 }
OLDNEW
« no previous file with comments | « content/browser/download/mock_download_file.cc ('k') | content/browser/renderer_host/resource_dispatcher_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698