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

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

Issue 114193009: [Download] Return DownloadInterruptReason from OnStartedCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } else { 386 } else {
387 DownloadMap::iterator item_iterator = downloads_.find(id); 387 DownloadMap::iterator item_iterator = downloads_.find(id);
388 // Trying to resume an interrupted download. 388 // Trying to resume an interrupted download.
389 if (item_iterator == downloads_.end() || 389 if (item_iterator == downloads_.end() ||
390 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { 390 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) {
391 // If the download is no longer known to the DownloadManager, then it was 391 // If the download is no longer known to the DownloadManager, then it was
392 // removed after it was resumed. Ignore. If the download is cancelled 392 // removed after it was resumed. Ignore. If the download is cancelled
393 // while resuming, then also ignore the request. 393 // while resuming, then also ignore the request.
394 info->request_handle.CancelRequest(); 394 info->request_handle.CancelRequest();
395 if (!on_started.is_null()) 395 if (!on_started.is_null())
396 on_started.Run(NULL, net::ERR_ABORTED); 396 on_started.Run(NULL, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED);
397 return; 397 return;
398 } 398 }
399 download = item_iterator->second; 399 download = item_iterator->second;
400 DCHECK_EQ(DownloadItem::INTERRUPTED, download->GetState()); 400 DCHECK_EQ(DownloadItem::INTERRUPTED, download->GetState());
401 download->MergeOriginInfoOnResume(*info); 401 download->MergeOriginInfoOnResume(*info);
402 } 402 }
403 403
404 base::FilePath default_download_directory; 404 base::FilePath default_download_directory;
405 if (delegate_) { 405 if (delegate_) {
406 base::FilePath website_save_directory; // Unused 406 base::FilePath website_save_directory; // Unused
(...skipping 23 matching lines...) Expand all
430 430
431 // For interrupted downloads, Start() will transition the state to 431 // For interrupted downloads, Start() will transition the state to
432 // IN_PROGRESS and consumers will be notified via OnDownloadUpdated(). 432 // IN_PROGRESS and consumers will be notified via OnDownloadUpdated().
433 // For new downloads, we notify here, rather than earlier, so that 433 // For new downloads, we notify here, rather than earlier, so that
434 // the download_file is bound to download and all the usual 434 // the download_file is bound to download and all the usual
435 // setters (e.g. Cancel) work. 435 // setters (e.g. Cancel) work.
436 if (new_download) 436 if (new_download)
437 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download)); 437 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, download));
438 438
439 if (!on_started.is_null()) 439 if (!on_started.is_null())
440 on_started.Run(download, net::OK); 440 on_started.Run(download, DOWNLOAD_INTERRUPT_REASON_NONE);
441 } 441 }
442 442
443 void DownloadManagerImpl::CheckForHistoryFilesRemoval() { 443 void DownloadManagerImpl::CheckForHistoryFilesRemoval() {
444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
445 for (DownloadMap::iterator it = downloads_.begin(); 445 for (DownloadMap::iterator it = downloads_.begin();
446 it != downloads_.end(); ++it) { 446 it != downloads_.end(); ++it) {
447 DownloadItemImpl* item = it->second; 447 DownloadItemImpl* item = it->second;
448 CheckForFileRemoval(item); 448 CheckForFileRemoval(item);
449 } 449 }
450 } 450 }
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (delegate_) 708 if (delegate_)
709 delegate_->OpenDownload(download); 709 delegate_->OpenDownload(download);
710 } 710 }
711 711
712 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 712 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
713 if (delegate_) 713 if (delegate_)
714 delegate_->ShowDownloadInShell(download); 714 delegate_->ShowDownloadInShell(download);
715 } 715 }
716 716
717 } // namespace content 717 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | content/browser/download/download_net_log_parameters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698