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

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

Issue 74523002: [Downloads] Update origin info after each response. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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 // File method ordering: Methods in this file are in the same order as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 case DOWNLOAD_INTERRUPT_REASON_USER_CANCELED: 889 case DOWNLOAD_INTERRUPT_REASON_USER_CANCELED:
890 case DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED: 890 case DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED:
891 case DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED: 891 case DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED:
892 mode = RESUME_MODE_INVALID; 892 mode = RESUME_MODE_INVALID;
893 break; 893 break;
894 } 894 }
895 895
896 return mode; 896 return mode;
897 } 897 }
898 898
899 void DownloadItemImpl::MergeOriginInfoOnResume(
900 const DownloadCreateInfo& new_create_info) {
901 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
902 DCHECK_EQ(RESUMING_INTERNAL, state_);
903 DCHECK(!new_create_info.url_chain.empty());
904
905 // We are going to tack on any new redirects to our list of redirects.
Randy Smith (Not in Mondays) 2013/11/18 22:15:56 So I can see two cases here: a) The validators mat
asanka 2013/11/19 23:54:19 For b) case, I chose not to overwrite the redirect
Randy Smith (Not in Mondays) 2013/11/20 22:32:18 When we resume, are we resuming from the URL at th
asanka 2013/11/21 18:11:08 We start from the end of the chain since that's th
906 std::vector<GURL>::const_iterator chain_iter =
907 new_create_info.url_chain.begin();
908 if (*chain_iter == url_chain_.back())
909 ++chain_iter;
910 url_chain_.insert(
911 url_chain_.end(), chain_iter, new_create_info.url_chain.end());
912 // TODO(asanka): Measure how URL chains change with resumption. Resumption
913 // requests are issued against the actual download URL and we don't expect any
914 // redirects.
915
916 // If the server precondition failed, then the download will be resumed
917 // automatically without validators.
918 etag_ = new_create_info.etag;
919 last_modified_time_ = new_create_info.last_modified;
920 content_disposition_ = new_create_info.content_disposition;
921 // TODO(asanka): Measure how validators change with resumption. I.e. An ETag
922 // should only change if we used it and the server responded with
923 // HTTP_PRECONDITION_FAILED.
924
925 // Don't update observers. This method is expected to be called just before a
926 // DownloadFile is created and Start() is called. The observers will be
927 // notified when the download transitions to the IN_PROGRESS state.
928 }
929
899 void DownloadItemImpl::NotifyRemoved() { 930 void DownloadItemImpl::NotifyRemoved() {
900 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadRemoved(this)); 931 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadRemoved(this));
901 } 932 }
902 933
903 void DownloadItemImpl::OnDownloadedFileRemoved() { 934 void DownloadItemImpl::OnDownloadedFileRemoved() {
904 file_externally_removed_ = true; 935 file_externally_removed_ = true;
905 VLOG(20) << __FUNCTION__ << " download=" << DebugString(true); 936 VLOG(20) << __FUNCTION__ << " download=" << DebugString(true);
906 UpdateObservers(); 937 UpdateObservers();
907 } 938 }
908 939
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 case RESUME_MODE_USER_CONTINUE: 1735 case RESUME_MODE_USER_CONTINUE:
1705 return "USER_CONTINUE"; 1736 return "USER_CONTINUE";
1706 case RESUME_MODE_USER_RESTART: 1737 case RESUME_MODE_USER_RESTART:
1707 return "USER_RESTART"; 1738 return "USER_RESTART";
1708 } 1739 }
1709 NOTREACHED() << "Unknown resume mode " << mode; 1740 NOTREACHED() << "Unknown resume mode " << mode;
1710 return "unknown"; 1741 return "unknown";
1711 } 1742 }
1712 1743
1713 } // namespace content 1744 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698