| 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_JOB_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 friend class ParallelDownloadJobTest; | 36 friend class ParallelDownloadJobTest; |
| 37 | 37 |
| 38 typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList; | 38 typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList; |
| 39 | 39 |
| 40 // Build multiple http requests for a new download, | 40 // Build multiple http requests for a new download, |
| 41 // the rest of the bytes starting from |bytes_received| will be equally | 41 // the rest of the bytes starting from |bytes_received| will be equally |
| 42 // distributed to each connection, including the original connection. | 42 // distributed to each connection, including the original connection. |
| 43 // the last connection may take additional bytes. | 43 // the last connection may take additional bytes. |
| 44 void ForkRequestsForNewDownload(int64_t bytes_received, int64_t total_bytes); | 44 void ForkRequestsForNewDownload(int64_t bytes_received, |
| 45 int64_t total_bytes, |
| 46 int request_count); |
| 45 | 47 |
| 46 // Build parallel requests to download the remaining slices. | 48 // Build parallel requests to download the remaining slices. |
| 47 // TODO(qinmin): remove ForkRequestsForNewDownload() and move the logic into | 49 // TODO(qinmin): remove ForkRequestsForNewDownload() and move the logic into |
| 48 // this function. | 50 // this function. |
| 49 void BuildParallelRequests(); | 51 void BuildParallelRequests(); |
| 50 | 52 |
| 51 // Create one range request, virtual for testing. | 53 // Create one range request, virtual for testing. |
| 52 virtual void CreateRequest(int64_t offset, int64_t length); | 54 virtual void CreateRequest(int64_t offset, int64_t length); |
| 53 | 55 |
| 54 // Number of concurrent requests for a new download, include the original | |
| 55 // request. | |
| 56 int request_num_; | |
| 57 | |
| 58 // Information about the initial request when download is started. | 56 // Information about the initial request when download is started. |
| 59 int64_t initial_request_offset_; | 57 int64_t initial_request_offset_; |
| 60 int64_t initial_request_length_; | 58 int64_t initial_request_length_; |
| 61 | 59 |
| 62 // Subsequent tasks to send range requests. | 60 // Subsequent tasks to send range requests. |
| 63 WorkerList workers_; | 61 WorkerList workers_; |
| 64 | 62 |
| 65 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob); | 63 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob); |
| 66 }; | 64 }; |
| 67 | 65 |
| 68 } // namespace content | 66 } // namespace content |
| 69 | 67 |
| 70 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ | 68 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ |
| OLD | NEW |