| OLD | NEW |
| 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 <unordered_map> | 9 #include <unordered_map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class CONTENT_EXPORT ParallelDownloadJob : public DownloadJobImpl, | 23 class CONTENT_EXPORT ParallelDownloadJob : public DownloadJobImpl, |
| 24 public DownloadWorker::Delegate { | 24 public DownloadWorker::Delegate { |
| 25 public: | 25 public: |
| 26 ParallelDownloadJob( | 26 ParallelDownloadJob( |
| 27 DownloadItemImpl* download_item, | 27 DownloadItemImpl* download_item, |
| 28 std::unique_ptr<DownloadRequestHandleInterface> request_handle, | 28 std::unique_ptr<DownloadRequestHandleInterface> request_handle, |
| 29 const DownloadCreateInfo& create_info); | 29 const DownloadCreateInfo& create_info); |
| 30 ~ParallelDownloadJob() override; | 30 ~ParallelDownloadJob() override; |
| 31 | 31 |
| 32 // DownloadJobImpl implementation. | 32 // DownloadJobImpl implementation. |
| 33 void Start() override; | |
| 34 void Cancel(bool user_cancel) override; | 33 void Cancel(bool user_cancel) override; |
| 35 void Pause() override; | 34 void Pause() override; |
| 36 void Resume(bool resume_request) override; | 35 void Resume(bool resume_request) override; |
| 37 void CancelRequestWithOffset(int64_t offset) override; | 36 void CancelRequestWithOffset(int64_t offset) override; |
| 38 | 37 |
| 39 protected: | 38 protected: |
| 39 // DownloadJobImpl implementation. |
| 40 void OnDownloadFileInitialized( |
| 41 const DownloadFile::InitializeCallback& callback, |
| 42 DownloadInterruptReason result) override; |
| 43 |
| 40 // Virtual for testing. | 44 // Virtual for testing. |
| 41 virtual int GetParallelRequestCount() const; | 45 virtual int GetParallelRequestCount() const; |
| 42 virtual int64_t GetMinSliceSize() const; | 46 virtual int64_t GetMinSliceSize() const; |
| 43 virtual int GetMinRemainingTimeInSeconds() const; | 47 virtual int GetMinRemainingTimeInSeconds() const; |
| 44 | 48 |
| 45 using WorkerMap = | 49 using WorkerMap = |
| 46 std::unordered_map<int64_t, std::unique_ptr<DownloadWorker>>; | 50 std::unordered_map<int64_t, std::unique_ptr<DownloadWorker>>; |
| 47 | 51 |
| 48 // Map from the offset position of the slice to the worker that downloads the | 52 // Map from the offset position of the slice to the worker that downloads the |
| 49 // slice. | 53 // slice. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 93 |
| 90 // If the download progress is canceled. | 94 // If the download progress is canceled. |
| 91 bool is_canceled_; | 95 bool is_canceled_; |
| 92 | 96 |
| 93 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob); | 97 DISALLOW_COPY_AND_ASSIGN(ParallelDownloadJob); |
| 94 }; | 98 }; |
| 95 | 99 |
| 96 } // namespace content | 100 } // namespace content |
| 97 | 101 |
| 98 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ | 102 #endif // CONTENT_BROWSER_DOWNLOAD_PARALLEL_DOWNLOAD_JOB_H_ |
| OLD | NEW |