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

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

Issue 10861002: Revert 152213 - Replace the DownloadFileManager with direct ownership of DownloadFile. (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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 if (size <= 0) { 331 if (size <= 0) {
331 Cancel(false); 332 Cancel(false);
332 return; 333 return;
333 } 334 }
334 wrote_to_completed_file_ = true; 335 wrote_to_completed_file_ = true;
335 download_->SetTotalBytes(size); 336 download_->SetTotalBytes(size);
336 download_->UpdateProgress(size, size, DownloadItem::kEmptyFileHash); 337 download_->UpdateProgress(size, size, DownloadItem::kEmptyFileHash);
337 // Must call OnAllDataSaved here in order for 338 // Must call OnAllDataSaved here in order for
338 // GDataDownloadObserver::ShouldUpload() to return true. 339 // GDataDownloadObserver::ShouldUpload() to return true.
339 // ShouldCompleteDownload() may depend on the gdata uploader to finish. 340 // ShouldCompleteDownload() may depend on the gdata uploader to finish.
340 download_->UpdateProgress(size, CurrentSpeed(), ""); 341 download_->OnAllDataSaved(size, DownloadItem::kEmptyFileHash);
341 download_->OnAllDataSaved(DownloadItem::kEmptyFileHash);
342 if (!download_manager_->GetDelegate() || 342 if (!download_manager_->GetDelegate() ||
343 download_manager_->GetDelegate()->ShouldCompleteDownload( 343 download_manager_->GetDelegate()->ShouldCompleteDownload(
344 download_, base::Bind(&SavePackage::Finish, this))) { 344 download_, base::Bind(&SavePackage::Finish, this))) {
345 Finish(); 345 Finish();
346 } 346 }
347 } 347 }
348 348
349 // On POSIX, the length of |pure_file_name| + |file_name_ext| is further 349 // On POSIX, the length of |pure_file_name| + |file_name_ext| is further
350 // restricted by NAME_MAX. The maximum allowed path looks like: 350 // restricted by NAME_MAX. The maximum allowed path looks like:
351 // '/path/to/save_dir' + '/' + NAME_MAX. 351 // '/path/to/save_dir' + '/' + NAME_MAX.
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 it != saved_failed_items_.end(); ++it) 734 it != saved_failed_items_.end(); ++it)
735 save_ids.push_back(it->second->save_id()); 735 save_ids.push_back(it->second->save_id());
736 736
737 BrowserThread::PostTask( 737 BrowserThread::PostTask(
738 BrowserThread::FILE, FROM_HERE, 738 BrowserThread::FILE, FROM_HERE,
739 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, 739 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap,
740 file_manager_, 740 file_manager_,
741 save_ids)); 741 save_ids));
742 742
743 if (download_) { 743 if (download_) {
744 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) { 744 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML)
745 download_->UpdateProgress(all_save_items_count_, CurrentSpeed(), ""); 745 download_->OnAllDataSaved(all_save_items_count_,
746 download_->OnAllDataSaved(DownloadItem::kEmptyFileHash); 746 DownloadItem::kEmptyFileHash);
747 }
748 download_->MarkAsComplete(); 747 download_->MarkAsComplete();
749 FinalizeDownloadEntry(); 748 FinalizeDownloadEntry();
750 } 749 }
751 } 750 }
752 751
753 // Called for updating end state. 752 // Called for updating end state.
754 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { 753 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) {
755 // Because we might have canceled this saving job before, 754 // Because we might have canceled this saving job before,
756 // so we might not find corresponding SaveItem. Just ignore it. 755 // so we might not find corresponding SaveItem. Just ignore it.
757 SaveItem* save_item = LookupItemInProcessBySaveId(save_id); 756 SaveItem* save_item = LookupItemInProcessBySaveId(save_id);
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 StopObservation(); 1361 StopObservation();
1363 } 1362 }
1364 1363
1365 void SavePackage::FinalizeDownloadEntry() { 1364 void SavePackage::FinalizeDownloadEntry() {
1366 DCHECK(download_); 1365 DCHECK(download_);
1367 DCHECK(download_manager_); 1366 DCHECK(download_manager_);
1368 1367
1369 download_manager_->SavePageDownloadFinished(download_); 1368 download_manager_->SavePageDownloadFinished(download_);
1370 StopObservation(); 1369 StopObservation();
1371 } 1370 }
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