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

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

Issue 2829853011: Polish the cleaning up url request code for parallel download. (Closed)
Patch Set: Created 3 years, 8 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
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_DOWNLOAD_JOB_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_JOB_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_JOB_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_JOB_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/byte_stream.h" 10 #include "content/browser/byte_stream.h"
(...skipping 28 matching lines...) Expand all
39 // Or return nullptr if the download is not associated with an active 39 // Or return nullptr if the download is not associated with an active
40 // WebContents. 40 // WebContents.
41 virtual WebContents* GetWebContents() const = 0; 41 virtual WebContents* GetWebContents() const = 0;
42 42
43 // Returns whether the download is parallelizable. The download may not send 43 // Returns whether the download is parallelizable. The download may not send
44 // parallel requests as it can be disabled through flags. 44 // parallel requests as it can be disabled through flags.
45 virtual bool IsParallelizable() const; 45 virtual bool IsParallelizable() const;
46 46
47 // Cancel a particular request starts from |offset|, while the download is not 47 // Cancel a particular request starts from |offset|, while the download is not
48 // canceled. Used in parallel download. 48 // canceled. Used in parallel download.
49 // TODO(xingliu): Remove this function if download job owns download file.
49 virtual void CancelRequestWithOffset(int64_t offset); 50 virtual void CancelRequestWithOffset(int64_t offset);
50 51
51 protected: 52 protected:
52 void StartDownload() const; 53 void StartDownload() const;
53 void Interrupt(DownloadInterruptReason reason); 54 void Interrupt(DownloadInterruptReason reason);
54 55
55 // Add a byte stream to the download sink. Return false if we start to 56 // Add a byte stream to the download sink. Return false if we start to
56 // destroy download file. 57 // destroy download file.
57 bool AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader, 58 bool AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader,
58 int64_t offset, 59 int64_t offset,
59 int64_t length); 60 int64_t length);
60 61
61 // Sets the potential length of the file. 62 // Sets the potential length of the file.
62 void SetPotentialFileLength(int64_t length); 63 void SetPotentialFileLength(int64_t length);
63 64
64 DownloadItemImpl* download_item_; 65 DownloadItemImpl* download_item_;
65 66
66 private: 67 private:
67 // If the download progress is paused by the user. 68 // If the download progress is paused by the user.
68 bool is_paused_; 69 bool is_paused_;
69 70
70 DISALLOW_COPY_AND_ASSIGN(DownloadJob); 71 DISALLOW_COPY_AND_ASSIGN(DownloadJob);
71 }; 72 };
72 73
73 } // namespace content 74 } // namespace content
74 75
75 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_JOB_H_ 76 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698