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

Side by Side Diff: content/browser/download/parallel_download_utils.h

Issue 2783473002: Fix issues and feature polishing for parallel download. (Closed)
Patch Set: Rebase. Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_
6 #define CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "content/browser/download/download_create_info.h" 10 #include "content/browser/download/download_create_info.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/public/browser/download_item.h" 12 #include "content/public/browser/download_item.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 // Return if the download should be a parallel download. 16 // Return if the download should be a parallel download.
17 CONTENT_EXPORT bool ShouldUseParallelDownload( 17 CONTENT_EXPORT bool ShouldUseParallelDownload(
18 const DownloadCreateInfo& create_info); 18 const DownloadCreateInfo& create_info);
19 19
20 // Return the slices to download for the remaining content. 20 // Chunks the content that starts from |current_offset|, into at most
21 // This function chunks the content into slices. 21 // std::max(|request_count|, 1) smaller slices.
22 // Each slice contains at least |min_slice_size| bytes unless |total_length|
23 // is less than |min_slice_size|.
24 // The last slice is half opened.
22 CONTENT_EXPORT std::vector<DownloadItem::ReceivedSlice> 25 CONTENT_EXPORT std::vector<DownloadItem::ReceivedSlice>
23 FindSlicesForRemainingContent(int64_t bytes_received, 26 FindSlicesForRemainingContent(int64_t current_offset,
24 int64_t content_length, 27 int64_t total_length,
25 int request_count); 28 int request_count,
29 int64_t min_slice_size);
26 30
27 // Given an array of slices that are received, returns an array of slices to 31 // Given an array of slices that are received, returns an array of slices to
28 // download. |received_slices| must be ordered by offsets. 32 // download. |received_slices| must be ordered by offsets.
29 CONTENT_EXPORT std::vector<DownloadItem::ReceivedSlice> FindSlicesToDownload( 33 CONTENT_EXPORT std::vector<DownloadItem::ReceivedSlice> FindSlicesToDownload(
30 const std::vector<DownloadItem::ReceivedSlice>& received_slices); 34 const std::vector<DownloadItem::ReceivedSlice>& received_slices);
31 35
32 // Adds or merges a new received slice into a vector of sorted slices. If the 36 // Adds or merges a new received slice into a vector of sorted slices. If the
33 // slice can be merged with the slice preceding it, merge the 2 slices. 37 // slice can be merged with the slice preceding it, merge the 2 slices.
34 // Otherwise, insert the slice and keep the vector sorted. Returns the index 38 // Otherwise, insert the slice and keep the vector sorted. Returns the index
35 // of the newly updated slice. 39 // of the newly updated slice.
(...skipping 14 matching lines...) Expand all
50 // Get the time delay to send parallel requests after the response of original 54 // Get the time delay to send parallel requests after the response of original
51 // request is handled. 55 // request is handled.
52 CONTENT_EXPORT base::TimeDelta GetParallelRequestDelayConfig(); 56 CONTENT_EXPORT base::TimeDelta GetParallelRequestDelayConfig();
53 57
54 // Print the states of received slices for debugging. 58 // Print the states of received slices for debugging.
55 CONTENT_EXPORT void DebugSlicesInfo(const DownloadItem::ReceivedSlices& slices); 59 CONTENT_EXPORT void DebugSlicesInfo(const DownloadItem::ReceivedSlices& slices);
56 60
57 } // namespace content 61 } // namespace content
58 62
59 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_ 63 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698