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/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "content/public/browser/download_item.h" | 11 #include "content/public/browser/download_item.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 // Find the first gap in an array of received slices and return it as the next | 15 // Find the first gap in an array of received slices and return it as the next |
16 // slice to download. If not found, return a slice that is to the end of all | 16 // slice to download. If not found, return a slice that is to the end of all |
17 // slices. |received_slices| must be ordered by offsets. | 17 // slices. |received_slices| must be ordered by offsets. |
18 CONTENT_EXPORT DownloadItem::ReceivedSlice FindNextSliceToDownload( | 18 CONTENT_EXPORT DownloadItem::ReceivedSlice FindNextSliceToDownload( |
19 const std::vector<DownloadItem::ReceivedSlice>& received_slices); | 19 const std::vector<DownloadItem::ReceivedSlice>& received_slices); |
20 | 20 |
| 21 // Adds a new received slice to a vector of sorted slices, and keep it sorted. |
| 22 // Returns the index of the newly inserted slice. |
| 23 CONTENT_EXPORT int AddReceivedSliceToSortedArray( |
| 24 const DownloadItem::ReceivedSlice& new_slice, |
| 25 std::vector<DownloadItem::ReceivedSlice>& received_slices); |
| 26 |
21 } // namespace content | 27 } // namespace content |
22 | 28 |
23 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_ | 29 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_UTILS_H_ |
OLD | NEW |