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

Unified Diff: content/browser/download/parallel_download_job.h

Issue 2689373003: Introduce ParallelDownloadJob. (Closed)
Patch Set: nits. 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e3914ed0cbb7fd000326aefc7d1140419eaab557
--- /dev/null
+++ b/content/browser/download/parallel_download_job.h
@@ -0,0 +1,59 @@
+// 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 <memory>
+#include <vector>
+
+#include "base/macros.h"
+#include "content/browser/download/download_job_impl.h"
+#include "content/browser/download/download_worker.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+// 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 DownloadJobImpl {
+ public:
+ ParallelDownloadJob(
+ DownloadItemImpl* download_item,
+ std::unique_ptr<DownloadRequestHandleInterface> request_handle);
+ ~ParallelDownloadJob() override;
+
+ // DownloadUrlJob implementation.
+ void Cancel(bool user_cancel) override;
+ void Pause() override;
+ void Resume(bool resume_request) override;
+
+ private:
+ friend class ParallelDownloadJobTest;
+
+ typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList;
+
+ // Build multiple http requests for a new download,
+ // the rest of the bytes starting from |bytes_received| will be equally
+ // distributed to each connection, including the original connection.
+ // the last connection may take additional bytes.
+ void ForkRequestsForNewDownload(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 for a new download, include the original
+ // request.
+ int request_num_;
+
+ // Subsequent tasks to send range requests.
+ WorkerList workers_;
+
+ DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_
« 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