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

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

Issue 2689373003: Introduce ParallelDownloadJob. (Closed)
Patch Set: nits. 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_
6 #define CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "content/browser/download/download_job_impl.h"
13 #include "content/browser/download/download_worker.h"
14 #include "content/common/content_export.h"
15
16 namespace content {
17
18 // DownloadJob that can create concurrent range requests to fetch different
19 // parts of the file.
20 // The original request is hold in base class DownloadUrlJob.
21 class CONTENT_EXPORT ParallelDownloadJob : public DownloadJobImpl {
22 public:
23 ParallelDownloadJob(
24 DownloadItemImpl* download_item,
25 std::unique_ptr<DownloadRequestHandleInterface> request_handle);
26 ~ParallelDownloadJob() override;
27
28 // DownloadUrlJob implementation.
29 void Cancel(bool user_cancel) override;
30 void Pause() override;
31 void Resume(bool resume_request) override;
32
33 private:
34 friend class ParallelDownloadJobTest;
35
36 typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList;
37
38 // Build multiple http requests for a new download,
39 // the rest of the bytes starting from |bytes_received| will be equally
40 // distributed to each connection, including the original connection.
41 // the last connection may take additional bytes.
42 void ForkRequestsForNewDownload(int64_t bytes_received, int64_t total_bytes);
43
44 // Create one range request, virtual for testing.
45 virtual void CreateRequest(int64_t offset, int64_t length);
46
47 // Number of concurrent requests for a new download, include the original
48 // request.
49 int request_num_;
50
51 // Subsequent tasks to send range requests.
52 WorkerList workers_;
53
54 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob);
55 };
56
57 } // namespace content
58
59 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_
OLDNEW
« no previous file with comments | « content/browser/download/mock_download_job.cc ('k') | content/browser/download/parallel_download_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698