Chromium Code Reviews| Index: content/browser/download/parallel_download_job.h |
| diff --git a/content/browser/download/parallel_download_job.h b/content/browser/download/parallel_download_job.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4733b34ab4af8744392ee7d99c96ff2c0766b22b |
| --- /dev/null |
| +++ b/content/browser/download/parallel_download_job.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ |
| +#define CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ |
| + |
| +#include "base/macros.h" |
| +#include "content/browser/download/download_url_job.h" |
| +#include "content/browser/download/download_url_task.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +class DownloadUrlTask; |
| + |
| +// DownloadJob that can create concurrent range requests to fetch different |
| +// parts of the file. |
| +// The original request is hold in base class DownloadUrlJob. |
| +class CONTENT_EXPORT ParallelDownloadJob : public DownloadUrlJob { |
| + public: |
| + typedef std::vector<std::unique_ptr<DownloadUrlTask>> TaskList; |
| + |
| + ParallelDownloadJob( |
| + 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
|
| + ~ParallelDownloadJob() override; |
| + |
| + // DownloadUrlJob implementation. |
| + void Cancel(bool user_cancel) override; |
| + void Pause() override; |
| + void Resume() override; |
| + |
| + private: |
| + friend class ParallelDownloadJobTest; |
| + |
| + // Create multiple http connections, the rest of the bytes will be equally |
| + // distributed to each connection, the last connection may take additional |
| + // bytes. |
| + void ForkParallelRequests(int64_t bytes_received, int64_t total_bytes); |
| + |
| + // Create one range request, virtual for testing. |
| + virtual void CreateRequest(int64_t offset, int64_t length); |
| + |
| + // Number of concurrent requests, include the original request. |
| + // Actual number of requests may be less than this, due to |min_length_|. |
| + int request_num_; |
| + |
| + // Minimum length for each range request. Requests with only a few bytes are |
| + // not preferred. |
| + int64_t min_length_; |
| + |
| + // Subsequent tasks to send range requests. |
| + TaskList tasks_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ |