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

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

Issue 2750853004: Add a delay to send the parallel requests. (Closed)
Patch Set: Work on 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
« no previous file with comments | « no previous file | content/browser/download/parallel_download_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/timer/timer.h"
12 #include "content/browser/download/download_job_impl.h" 13 #include "content/browser/download/download_job_impl.h"
13 #include "content/browser/download/download_worker.h" 14 #include "content/browser/download/download_worker.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 // DownloadJob that can create concurrent range requests to fetch different 19 // DownloadJob that can create concurrent range requests to fetch different
19 // parts of the file. 20 // parts of the file.
20 // The original request is hold in base class DownloadUrlJob. 21 // The original request is hold in base class DownloadUrlJob.
21 class CONTENT_EXPORT ParallelDownloadJob : public DownloadJobImpl { 22 class CONTENT_EXPORT ParallelDownloadJob : public DownloadJobImpl {
(...skipping 16 matching lines...) Expand all
38 typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList; 39 typedef std::vector<std::unique_ptr<DownloadWorker>> WorkerList;
39 40
40 // Build multiple http requests for a new download, 41 // Build multiple http requests for a new download,
41 // the rest of the bytes starting from |bytes_received| will be equally 42 // the rest of the bytes starting from |bytes_received| will be equally
42 // distributed to each connection, including the original connection. 43 // distributed to each connection, including the original connection.
43 // the last connection may take additional bytes. 44 // the last connection may take additional bytes.
44 void ForkRequestsForNewDownload(int64_t bytes_received, 45 void ForkRequestsForNewDownload(int64_t bytes_received,
45 int64_t total_bytes, 46 int64_t total_bytes,
46 int request_count); 47 int request_count);
47 48
49 // Build parallel requests after a delay, to effectively measure the single
50 // stream bandwidth.
51 void BuildParallelRequestAfterDelay();
52
48 // Build parallel requests to download the remaining slices. 53 // Build parallel requests to download the remaining slices.
49 // TODO(qinmin): remove ForkRequestsForNewDownload() and move the logic into 54 // TODO(qinmin): remove ForkRequestsForNewDownload() and move the logic into
50 // this function. 55 // this function.
51 void BuildParallelRequests(); 56 void BuildParallelRequests();
52 57
53 // Create one range request, virtual for testing. 58 // Create one range request, virtual for testing.
54 virtual void CreateRequest(int64_t offset, int64_t length); 59 virtual void CreateRequest(int64_t offset, int64_t length);
55 60
56 // Information about the initial request when download is started. 61 // Information about the initial request when download is started.
57 int64_t initial_request_offset_; 62 int64_t initial_request_offset_;
58 int64_t initial_request_length_; 63 int64_t initial_request_length_;
59 64
60 // Subsequent tasks to send range requests. 65 // Subsequent tasks to send range requests.
61 WorkerList workers_; 66 WorkerList workers_;
62 67
68 // Used to send parallel requests after a delay based on Finch config.
69 base::OneShotTimer timer_;
70
71 // If we have sent parallel requests.
72 bool requests_sent_;
73
63 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob); 74 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob);
64 }; 75 };
65 76
66 } // namespace content 77 } // namespace content
67 78
68 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ 79 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/parallel_download_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698