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

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

Issue 2727143005: Change FindNextSliceToDownload() into FindSlicesToDownload() (Closed)
Patch Set: 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
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_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
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "content/browser/download/download_job_impl.h" 12 #include "content/browser/download/download_job_impl.h"
13 #include "content/browser/download/download_worker.h" 13 #include "content/browser/download/download_worker.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 // DownloadJob that can create concurrent range requests to fetch different 18 // DownloadJob that can create concurrent range requests to fetch different
19 // parts of the file. 19 // parts of the file.
20 // The original request is hold in base class DownloadUrlJob. 20 // The original request is hold in base class DownloadUrlJob.
21 class CONTENT_EXPORT ParallelDownloadJob : public DownloadJobImpl { 21 class CONTENT_EXPORT ParallelDownloadJob : public DownloadJobImpl {
22 public: 22 public:
23 ParallelDownloadJob( 23 ParallelDownloadJob(
24 DownloadItemImpl* download_item, 24 DownloadItemImpl* download_item,
25 std::unique_ptr<DownloadRequestHandleInterface> request_handle); 25 std::unique_ptr<DownloadRequestHandleInterface> request_handle,
26 const DownloadCreateInfo& create_info);
26 ~ParallelDownloadJob() override; 27 ~ParallelDownloadJob() override;
27 28
28 // DownloadUrlJob implementation. 29 // DownloadUrlJob implementation.
30 void Start() override;
29 void Cancel(bool user_cancel) override; 31 void Cancel(bool user_cancel) override;
30 void Pause() override; 32 void Pause() override;
31 void Resume(bool resume_request) override; 33 void Resume(bool resume_request) override;
32 34
33 private: 35 private:
34 friend class ParallelDownloadJobTest; 36 friend class ParallelDownloadJobTest;
35 37
36 typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList; 38 typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList;
37 39
38 // Build multiple http requests for a new download, 40 // Build multiple http requests for a new download,
39 // 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
40 // distributed to each connection, including the original connection. 42 // distributed to each connection, including the original connection.
41 // the last connection may take additional bytes. 43 // the last connection may take additional bytes.
42 void ForkRequestsForNewDownload(int64_t bytes_received, int64_t total_bytes); 44 void ForkRequestsForNewDownload(int64_t bytes_received, int64_t total_bytes);
43 45
44 // Create one range request, virtual for testing. 46 // Create one range request, virtual for testing.
45 virtual void CreateRequest(int64_t offset, int64_t length); 47 virtual void CreateRequest(int64_t offset, int64_t length);
46 48
47 // Number of concurrent requests for a new download, include the original 49 // Number of concurrent requests for a new download, include the original
48 // request. 50 // request.
49 int request_num_; 51 int request_num_;
50 52
53 // Information about the initial request when download is started.
54 int64_t initial_request_offset_;
55 int64_t initial_request_length_;
56
51 // Subsequent tasks to send range requests. 57 // Subsequent tasks to send range requests.
52 WorkerList workers_; 58 WorkerList workers_;
53 59
54 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob); 60 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob);
55 }; 61 };
56 62
57 } // namespace content 63 } // namespace content
58 64
59 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ 65 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698