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

Side by Side Diff: chrome/browser/download/download_manager.cc

Issue 160627: Fix download cancelling from the save dialog (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "chrome/browser/download/download_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 int request_id) { 959 int request_id) {
960 rdh->CancelRequest(render_process_id, request_id, false); 960 rdh->CancelRequest(render_process_id, request_id, false);
961 } 961 }
962 962
963 void DownloadManager::DownloadCancelled(int32 download_id) { 963 void DownloadManager::DownloadCancelled(int32 download_id) {
964 DownloadMap::iterator it = in_progress_.find(download_id); 964 DownloadMap::iterator it = in_progress_.find(download_id);
965 if (it == in_progress_.end()) 965 if (it == in_progress_.end())
966 return; 966 return;
967 DownloadItem* download = it->second; 967 DownloadItem* download = it->second;
968 968
969 CancelDownloadRequest(download->render_process_id(), download->request_id());
970
971 // Clean up will happen when the history system create callback runs if we 969 // Clean up will happen when the history system create callback runs if we
972 // don't have a valid db_handle yet. 970 // don't have a valid db_handle yet.
973 if (download->db_handle() != kUninitializedHandle) { 971 if (download->db_handle() != kUninitializedHandle) {
974 in_progress_.erase(it); 972 in_progress_.erase(it);
975 UpdateHistoryForDownload(download); 973 UpdateHistoryForDownload(download);
976 } 974 }
977 975
976 DownloadCancelledInternal(download_id,
977 download->render_process_id(),
978 download->request_id());
979 }
980
981 void DownloadManager::DownloadCancelledInternal(int download_id,
982 int render_process_id,
983 int request_id) {
984 // Cancel the network request.
985 CancelDownloadRequest(render_process_id, request_id);
986
978 // Tell the file manager to cancel the download. 987 // Tell the file manager to cancel the download.
979 file_manager_->RemoveDownload(download->id(), this); // On the UI thread 988 file_manager_->RemoveDownload(download_id, this); // On the UI thread
980 file_loop_->PostTask(FROM_HERE, 989 file_loop_->PostTask(FROM_HERE,
981 NewRunnableMethod(file_manager_, 990 NewRunnableMethod(file_manager_,
982 &DownloadFileManager::CancelDownload, 991 &DownloadFileManager::CancelDownload,
983 download->id())); 992 download_id));
984 } 993 }
985 994
986 void DownloadManager::PauseDownload(int32 download_id, bool pause) { 995 void DownloadManager::PauseDownload(int32 download_id, bool pause) {
987 DownloadMap::iterator it = in_progress_.find(download_id); 996 DownloadMap::iterator it = in_progress_.find(download_id);
988 if (it != in_progress_.end()) { 997 if (it != in_progress_.end()) {
989 DownloadItem* download = it->second; 998 DownloadItem* download = it->second;
990 if (pause == download->is_paused()) 999 if (pause == download->is_paused())
991 return; 1000 return;
992 1001
993 // Inform the ResourceDispatcherHost of the new pause state. 1002 // Inform the ResourceDispatcherHost of the new pause state.
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 DownloadCreateInfo* info = reinterpret_cast<DownloadCreateInfo*>(params); 1388 DownloadCreateInfo* info = reinterpret_cast<DownloadCreateInfo*>(params);
1380 if (info->save_as) 1389 if (info->save_as)
1381 last_download_path_ = path.DirName(); 1390 last_download_path_ = path.DirName();
1382 ContinueStartDownload(info, path); 1391 ContinueStartDownload(info, path);
1383 } 1392 }
1384 1393
1385 void DownloadManager::FileSelectionCanceled(void* params) { 1394 void DownloadManager::FileSelectionCanceled(void* params) {
1386 // The user didn't pick a place to save the file, so need to cancel the 1395 // The user didn't pick a place to save the file, so need to cancel the
1387 // download that's already in progress to the temporary location. 1396 // download that's already in progress to the temporary location.
1388 DownloadCreateInfo* info = reinterpret_cast<DownloadCreateInfo*>(params); 1397 DownloadCreateInfo* info = reinterpret_cast<DownloadCreateInfo*>(params);
1389 file_loop_->PostTask(FROM_HERE, 1398 DownloadCancelledInternal(info->download_id,
1390 NewRunnableMethod(file_manager_, &DownloadFileManager::CancelDownload, 1399 info->render_process_id,
1391 info->download_id)); 1400 info->request_id);
1392 } 1401 }
1393 1402
1394 void DownloadManager::DeleteDownload(const FilePath& path) { 1403 void DownloadManager::DeleteDownload(const FilePath& path) {
1395 file_loop_->PostTask(FROM_HERE, NewRunnableFunction( 1404 file_loop_->PostTask(FROM_HERE, NewRunnableFunction(
1396 &DownloadFileManager::DeleteFile, FilePath(path))); 1405 &DownloadFileManager::DeleteFile, FilePath(path)));
1397 } 1406 }
1398 1407
1399 1408
1400 void DownloadManager::DangerousDownloadValidated(DownloadItem* download) { 1409 void DownloadManager::DangerousDownloadValidated(DownloadItem* download) {
1401 DCHECK_EQ(DownloadItem::DANGEROUS, download->safety_state()); 1410 DCHECK_EQ(DownloadItem::DANGEROUS, download->safety_state());
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 1535
1527 if (contents) 1536 if (contents)
1528 contents->OnStartDownload(download); 1537 contents->OnStartDownload(download);
1529 } 1538 }
1530 1539
1531 // Clears the last download path, used to initialize "save as" dialogs. 1540 // Clears the last download path, used to initialize "save as" dialogs.
1532 void DownloadManager::ClearLastDownloadPath() { 1541 void DownloadManager::ClearLastDownloadPath() {
1533 last_download_path_ = FilePath(); 1542 last_download_path_ = FilePath();
1534 } 1543 }
1535 1544
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698