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

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

Issue 2728673003: Add a utility function to calculate the next slice to download (Closed)
Patch Set: addressing comments Created 3 years, 9 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
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/download/parallel_download_utils.h » ('j') | 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) 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 27 matching lines...) Expand all
38 #include "base/strings/utf_string_conversions.h" 38 #include "base/strings/utf_string_conversions.h"
39 #include "content/browser/download/download_create_info.h" 39 #include "content/browser/download/download_create_info.h"
40 #include "content/browser/download/download_file.h" 40 #include "content/browser/download/download_file.h"
41 #include "content/browser/download/download_interrupt_reasons_impl.h" 41 #include "content/browser/download/download_interrupt_reasons_impl.h"
42 #include "content/browser/download/download_item_impl_delegate.h" 42 #include "content/browser/download/download_item_impl_delegate.h"
43 #include "content/browser/download/download_job_factory.h" 43 #include "content/browser/download/download_job_factory.h"
44 #include "content/browser/download/download_job_impl.h" 44 #include "content/browser/download/download_job_impl.h"
45 #include "content/browser/download/download_net_log_parameters.h" 45 #include "content/browser/download/download_net_log_parameters.h"
46 #include "content/browser/download/download_request_handle.h" 46 #include "content/browser/download/download_request_handle.h"
47 #include "content/browser/download/download_stats.h" 47 #include "content/browser/download/download_stats.h"
48 #include "content/browser/download/parallel_download_utils.h"
48 #include "content/browser/renderer_host/render_view_host_impl.h" 49 #include "content/browser/renderer_host/render_view_host_impl.h"
49 #include "content/browser/web_contents/web_contents_impl.h" 50 #include "content/browser/web_contents/web_contents_impl.h"
50 #include "content/public/browser/browser_context.h" 51 #include "content/public/browser/browser_context.h"
51 #include "content/public/browser/browser_thread.h" 52 #include "content/public/browser/browser_thread.h"
52 #include "content/public/browser/content_browser_client.h" 53 #include "content/public/browser/content_browser_client.h"
53 #include "content/public/browser/download_danger_type.h" 54 #include "content/public/browser/download_danger_type.h"
54 #include "content/public/browser/download_interrupt_reasons.h" 55 #include "content/public/browser/download_interrupt_reasons.h"
55 #include "content/public/browser/download_url_parameters.h" 56 #include "content/public/browser/download_url_parameters.h"
56 #include "content/public/browser/storage_partition.h" 57 #include "content/public/browser/storage_partition.h"
57 #include "content/public/common/content_features.h" 58 #include "content/public/common/content_features.h"
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 site_url_); 1938 site_url_);
1938 1939
1939 // Avoid using the WebContents even if it's still around. Resumption requests 1940 // Avoid using the WebContents even if it's still around. Resumption requests
1940 // are consistently routed through the no-renderer code paths so that the 1941 // are consistently routed through the no-renderer code paths so that the
1941 // request will not be dropped if the WebContents (and by extension, the 1942 // request will not be dropped if the WebContents (and by extension, the
1942 // associated renderer) goes away before a response is received. 1943 // associated renderer) goes away before a response is received.
1943 std::unique_ptr<DownloadUrlParameters> download_params( 1944 std::unique_ptr<DownloadUrlParameters> download_params(
1944 new DownloadUrlParameters(GetURL(), 1945 new DownloadUrlParameters(GetURL(),
1945 storage_partition->GetURLRequestContext())); 1946 storage_partition->GetURLRequestContext()));
1946 download_params->set_file_path(GetFullPath()); 1947 download_params->set_file_path(GetFullPath());
1947 download_params->set_offset(GetReceivedBytes()); 1948 if (received_slices_.size() > 0) {
1949 ReceivedSlice next_slice = FindNextSliceToDownload(received_slices_);
1950 download_params->set_offset(next_slice.offset);
1951 download_params->set_length(next_slice.received_bytes);
1952 } else {
1953 download_params->set_offset(GetReceivedBytes());
1954 }
1948 download_params->set_last_modified(GetLastModifiedTime()); 1955 download_params->set_last_modified(GetLastModifiedTime());
1949 download_params->set_etag(GetETag()); 1956 download_params->set_etag(GetETag());
1950 download_params->set_hash_of_partial_file(hash_); 1957 download_params->set_hash_of_partial_file(hash_);
1951 download_params->set_hash_state(std::move(hash_state_)); 1958 download_params->set_hash_state(std::move(hash_state_));
1952 1959
1953 // Note that resumed downloads disallow redirects. Hence the referrer URL 1960 // Note that resumed downloads disallow redirects. Hence the referrer URL
1954 // (which is the contents of the Referer header for the last download request) 1961 // (which is the contents of the Referer header for the last download request)
1955 // will only be sent to the URL returned by GetURL(). 1962 // will only be sent to the URL returned by GetURL().
1956 download_params->set_referrer( 1963 download_params->set_referrer(
1957 Referrer(GetReferrerUrl(), blink::WebReferrerPolicyAlways)); 1964 Referrer(GetReferrerUrl(), blink::WebReferrerPolicyAlways));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 case RESUME_MODE_USER_CONTINUE: 2143 case RESUME_MODE_USER_CONTINUE:
2137 return "USER_CONTINUE"; 2144 return "USER_CONTINUE";
2138 case RESUME_MODE_USER_RESTART: 2145 case RESUME_MODE_USER_RESTART:
2139 return "USER_RESTART"; 2146 return "USER_RESTART";
2140 } 2147 }
2141 NOTREACHED() << "Unknown resume mode " << mode; 2148 NOTREACHED() << "Unknown resume mode " << mode;
2142 return "unknown"; 2149 return "unknown";
2143 } 2150 }
2144 2151
2145 } // namespace content 2152 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/download/parallel_download_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698