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

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

Issue 2689373003: Introduce ParallelDownloadJob. (Closed)
Patch Set: Make windows compiler happy. Created 3 years, 10 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 "base/macros.h"
9 #include "content/browser/download/download_url_job.h"
10 #include "content/browser/download/download_url_task.h"
11 #include "content/common/content_export.h"
12
13 namespace content {
14
15 class DownloadUrlTask;
16
17 // DownloadJob that can create concurrent range requests to fetch different
18 // parts of the file.
19 // The original request is hold in base class DownloadUrlJob.
20 class CONTENT_EXPORT ParallelDownloadJob : public DownloadUrlJob {
21 public:
22 typedef std::vector<std::unique_ptr<DownloadUrlTask>> TaskList;
23
24 ParallelDownloadJob(
25 std::unique_ptr<DownloadRequestHandleInterface> request_handle);
asanka 2017/02/16 16:27:39 explicit
xingliu 2017/02/20 18:59:11 Done. Same as DownloadUrlJob, now it also pass Dow
26 ~ParallelDownloadJob() override;
27
28 // DownloadUrlJob implementation.
29 void Cancel(bool user_cancel) override;
30 void Pause() override;
31 void Resume() override;
32
33 private:
34 friend class ParallelDownloadJobTest;
35
36 // Create multiple http connections, the rest of the bytes will be equally
37 // distributed to each connection, the last connection may take additional
38 // bytes.
39 void ForkParallelRequests(int64_t bytes_received, int64_t total_bytes);
40
41 // Create one range request, virtual for testing.
42 virtual void CreateRequest(int64_t offset, int64_t length);
43
44 // Number of concurrent requests, include the original request.
45 // Actual number of requests may be less than this, due to |min_length_|.
46 int request_num_;
47
48 // Minimum length for each range request. Requests with only a few bytes are
49 // not preferred.
50 int64_t min_length_;
51
52 // Subsequent tasks to send range requests.
53 TaskList tasks_;
54
55 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob);
56 };
57
58 } // namespace content
59
60 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698