| OLD | NEW |
| 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 // Finch parameter key value for minimum slice size in bytes to use parallel |
| 17 // download. |
| 18 constexpr char kMinSliceSizeFinchKey[] = "min_slice_size"; |
| 19 |
| 20 // Finch parameter key value for number of parallel requests in a parallel |
| 21 // download, including the original request. |
| 22 constexpr char kParallelRequestCountFinchKey[] = "request_count"; |
| 23 |
| 24 // Finch parameter key value for the delay time in milliseconds to send |
| 25 // parallel requests after response of the original request is handled. |
| 26 constexpr char kParallelRequestDelayFinchKey[] = "parallel_request_delay"; |
| 27 |
| 28 // Finch parameter key value for the remaining time in seconds that is required |
| 29 // to send parallel requests. |
| 30 constexpr char kParallelRequestRemainingTimeFinchKey[] = |
| 31 "parallel_request_remaining_time"; |
| 32 |
| 16 // Chunks the content that starts from |current_offset|, into at most | 33 // Chunks the content that starts from |current_offset|, into at most |
| 17 // std::max(|request_count|, 1) smaller slices. | 34 // std::max(|request_count|, 1) smaller slices. |
| 18 // Each slice contains at least |min_slice_size| bytes unless |total_length| | 35 // Each slice contains at least |min_slice_size| bytes unless |total_length| |
| 19 // is less than |min_slice_size|. | 36 // is less than |min_slice_size|. |
| 20 // The last slice is half opened. | 37 // The last slice is half opened. |
| 21 CONTENT_EXPORT std::vector<DownloadItem::ReceivedSlice> | 38 CONTENT_EXPORT std::vector<DownloadItem::ReceivedSlice> |
| 22 FindSlicesForRemainingContent(int64_t current_offset, | 39 FindSlicesForRemainingContent(int64_t current_offset, |
| 23 int64_t total_length, | 40 int64_t total_length, |
| 24 int request_count, | 41 int request_count, |
| 25 int64_t min_slice_size); | 42 int64_t min_slice_size); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 CONTENT_EXPORT void DebugSlicesInfo(const DownloadItem::ReceivedSlices& slices); | 75 CONTENT_EXPORT void DebugSlicesInfo(const DownloadItem::ReceivedSlices& slices); |
| 59 | 76 |
| 60 // Given an ordered array of slices, get the maximum size of a contiguous data | 77 // Given an ordered array of slices, get the maximum size of a contiguous data |
| 61 // block that starts from offset 0. If the first slice doesn't start from offset | 78 // block that starts from offset 0. If the first slice doesn't start from offset |
| 62 // 0, return 0. | 79 // 0, return 0. |
| 63 CONTENT_EXPORT int64_t GetMaxContiguousDataBlockSizeFromBeginning( | 80 CONTENT_EXPORT int64_t GetMaxContiguousDataBlockSizeFromBeginning( |
| 64 const DownloadItem::ReceivedSlices& slices); | 81 const DownloadItem::ReceivedSlices& slices); |
| 65 } // namespace content | 82 } // namespace content |
| 66 | 83 |
| 67 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_ | 84 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_ |
| OLD | NEW |