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

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

Issue 2674973003: Adding a DownloadRestrictions group policy. (Closed)
Patch Set: Some oups.... :-) Created 3 years, 6 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
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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 WebContents* DownloadItemImpl::GetWebContents() const { 883 WebContents* DownloadItemImpl::GetWebContents() const {
884 // TODO(rdsmith): Remove null check after removing GetWebContents() from 884 // TODO(rdsmith): Remove null check after removing GetWebContents() from
885 // paths that might be used by DownloadItems created from history import. 885 // paths that might be used by DownloadItems created from history import.
886 // Currently such items have null request_handle_s, where other items 886 // Currently such items have null request_handle_s, where other items
887 // (regular and SavePackage downloads) have actual objects off the pointer. 887 // (regular and SavePackage downloads) have actual objects off the pointer.
888 if (job_) 888 if (job_)
889 return job_->GetWebContents(); 889 return job_->GetWebContents();
890 return nullptr; 890 return nullptr;
891 } 891 }
892 892
893 void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type) { 893 void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type,
894 DownloadInterruptReason reason) {
894 DCHECK_CURRENTLY_ON(BrowserThread::UI); 895 DCHECK_CURRENTLY_ON(BrowserThread::UI);
895 DCHECK(AllDataSaved()); 896 DCHECK(AllDataSaved());
896 897
897 // Danger type is only allowed to be set on an active download after all data 898 // Danger type is only allowed to be set on an active download after all data
898 // has been saved. This excludes all other states. In particular, 899 // has been saved. This excludes all other states. In particular,
899 // OnContentCheckCompleted() isn't allowed on an INTERRUPTED download since 900 // OnContentCheckCompleted() isn't allowed on an INTERRUPTED download since
900 // such an interruption would need to happen between OnAllDataSaved() and 901 // such an interruption would need to happen between OnAllDataSaved() and
901 // OnContentCheckCompleted() during which no disk or network activity 902 // OnContentCheckCompleted() during which no disk or network activity
902 // should've taken place. 903 // should've taken place.
903 DCHECK_EQ(state_, IN_PROGRESS_INTERNAL); 904 DCHECK_EQ(state_, IN_PROGRESS_INTERNAL);
904 DVLOG(20) << __func__ << "() danger_type=" << danger_type 905 DVLOG(20) << __func__ << "() danger_type=" << danger_type
905 << " download=" << DebugString(true); 906 << " download=" << DebugString(true);
906 SetDangerType(danger_type); 907 SetDangerType(danger_type);
908 if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) {
909 InterruptAndDiscardPartialState(reason);
910 DCHECK_EQ(RESUME_MODE_INVALID, GetResumeMode());
911 }
907 UpdateObservers(); 912 UpdateObservers();
908 } 913 }
909 914
910 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 915 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
911 open_when_complete_ = open; 916 open_when_complete_ = open;
912 } 917 }
913 918
914 void DownloadItemImpl::SetOpened(bool opened) { 919 void DownloadItemImpl::SetOpened(bool opened) {
915 opened_ = opened; 920 opened_ = opened;
916 } 921 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 // We also can't continue if we don't have some verifier to make sure 997 // We also can't continue if we don't have some verifier to make sure
993 // we're getting the same file. 998 // we're getting the same file.
994 bool restart_required = 999 bool restart_required =
995 (GetFullPath().empty() || (etag_.empty() && last_modified_time_.empty())); 1000 (GetFullPath().empty() || (etag_.empty() && last_modified_time_.empty()));
996 1001
997 // We won't auto-restart if we've used up our attempts or the 1002 // We won't auto-restart if we've used up our attempts or the
998 // download has been paused by user action. 1003 // download has been paused by user action.
999 bool user_action_required = 1004 bool user_action_required =
1000 (auto_resume_count_ >= kMaxAutoResumeAttempts || IsPaused()); 1005 (auto_resume_count_ >= kMaxAutoResumeAttempts || IsPaused());
1001 1006
1002 switch(last_reason_) { 1007 switch (last_reason_) {
1003 case DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR: 1008 case DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR:
1004 case DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT: 1009 case DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT:
1005 case DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH: 1010 case DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH:
1006 break; 1011 break;
1007 1012
1008 case DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE: 1013 case DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE:
1009 // The server disagreed with the file offset that we sent. 1014 // The server disagreed with the file offset that we sent.
1010 1015
1011 case DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH: 1016 case DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH:
1012 // The file on disk was found to not match the expected hash. Discard and 1017 // The file on disk was found to not match the expected hash. Discard and
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 case RESUME_MODE_USER_CONTINUE: 2347 case RESUME_MODE_USER_CONTINUE:
2343 return "USER_CONTINUE"; 2348 return "USER_CONTINUE";
2344 case RESUME_MODE_USER_RESTART: 2349 case RESUME_MODE_USER_RESTART:
2345 return "USER_RESTART"; 2350 return "USER_RESTART";
2346 } 2351 }
2347 NOTREACHED() << "Unknown resume mode " << mode; 2352 NOTREACHED() << "Unknown resume mode " << mode;
2348 return "unknown"; 2353 return "unknown";
2349 } 2354 }
2350 2355
2351 } // namespace content 2356 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698