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

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

Issue 2767593003: Handle early pause, cancel for parallel requests. (Closed)
Patch Set: Work on feedback. 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
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"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/public/browser/download_danger_type.h" 12 #include "content/public/browser/download_danger_type.h"
13 #include "content/public/browser/download_interrupt_reasons.h" 13 #include "content/public/browser/download_interrupt_reasons.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 class DownloadItemImpl; 17 class DownloadItemImpl;
18 class WebContents; 18 class WebContents;
19 19
20 // DownloadJob lives on UI thread and subclasses implement actual download logic 20 // DownloadJob lives on UI thread and subclasses implement actual download logic
21 // and interact with DownloadItemImpl. 21 // and interact with DownloadItemImpl.
22 // The base class is a friend class of DownloadItemImpl. 22 // The base class is a friend class of DownloadItemImpl.
23 class CONTENT_EXPORT DownloadJob { 23 class CONTENT_EXPORT DownloadJob {
24 public: 24 public:
25 explicit DownloadJob(DownloadItemImpl* download_item); 25 explicit DownloadJob(DownloadItemImpl* download_item);
26 virtual ~DownloadJob(); 26 virtual ~DownloadJob();
27 27
28 // Download operations. 28 // Download operations.
29 virtual void Start() = 0; 29 virtual void Start() = 0;
30 virtual void Cancel(bool user_cancel) = 0; 30 virtual void Cancel(bool user_cancel);
31 virtual void Pause(); 31 virtual void Pause();
32 virtual void Resume(bool resume_request); 32 virtual void Resume(bool resume_request);
33 33
34 bool is_paused() const { return is_paused_; } 34 bool is_paused() const { return is_paused_; }
35 bool is_canceled() const { return is_canceled_; }
35 36
36 // Return the WebContents associated with the download. Usually used to 37 // Return the WebContents associated with the download. Usually used to
37 // associate a browser window for any UI that needs to be displayed to the 38 // associate a browser window for any UI that needs to be displayed to the
38 // user. 39 // user.
39 // Or return nullptr if the download is not associated with an active 40 // Or return nullptr if the download is not associated with an active
40 // WebContents. 41 // WebContents.
41 virtual WebContents* GetWebContents() const = 0; 42 virtual WebContents* GetWebContents() const = 0;
42 43
43 protected: 44 protected:
44 void StartDownload() const; 45 void StartDownload() const;
45 void Interrupt(DownloadInterruptReason reason); 46 void Interrupt(DownloadInterruptReason reason);
46 47
47 // Add a byte stream to the download sink. 48 // Add a byte stream to the download sink. Return false if we start to
48 void AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader, 49 // destroy download file.
50 bool AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader,
49 int64_t offset, 51 int64_t offset,
50 int64_t length); 52 int64_t length);
51 53
52 DownloadItemImpl* download_item_; 54 DownloadItemImpl* download_item_;
53 55
54 private: 56 private:
55 // If the download progress is paused by the user. 57 // If the download progress is paused by the user.
56 bool is_paused_; 58 bool is_paused_;
57 59
60 // If the download progress is canceled.
61 bool is_canceled_;
62
58 DISALLOW_COPY_AND_ASSIGN(DownloadJob); 63 DISALLOW_COPY_AND_ASSIGN(DownloadJob);
59 }; 64 };
60 65
61 } // namespace content 66 } // namespace content
62 67
63 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_JOB_H_ 68 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_JOB_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_job.cc » ('j') | content/browser/download/parallel_download_job.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698