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

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

Issue 2752603002: Propagate server response error and interrupt the download. (Closed)
Patch Set: Merge recent changes in the tree. 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 | « content/browser/download/download_job.cc ('k') | content/browser/download/download_worker.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_DOWNLOAD_WORKER_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 13 matching lines...) Expand all
24 class DownloadWorker : public UrlDownloader::Delegate { 24 class DownloadWorker : public UrlDownloader::Delegate {
25 public: 25 public:
26 class Delegate { 26 class Delegate {
27 public: 27 public:
28 // Called when the the byte stream is established after server response is 28 // Called when the the byte stream is established after server response is
29 // handled. The stream contains data starts from |offset| of the 29 // handled. The stream contains data starts from |offset| of the
30 // destination file. 30 // destination file.
31 virtual void OnByteStreamReady( 31 virtual void OnByteStreamReady(
32 DownloadWorker* worker, 32 DownloadWorker* worker,
33 std::unique_ptr<ByteStreamReader> stream_reader) = 0; 33 std::unique_ptr<ByteStreamReader> stream_reader) = 0;
34 // Called when there is an error caused by the server response.
35 virtual void OnServerResponseError(DownloadWorker* worker,
36 DownloadInterruptReason reason) = 0;
34 }; 37 };
35 38
36 DownloadWorker(DownloadWorker::Delegate* delegate, 39 DownloadWorker(DownloadWorker::Delegate* delegate,
37 int64_t offset, 40 int64_t offset,
38 int64_t length); 41 int64_t length);
39 virtual ~DownloadWorker(); 42 virtual ~DownloadWorker();
40 43
41 int64_t offset() const { return offset_; } 44 int64_t offset() const { return offset_; }
42 int64_t length() const { return length_; } 45 int64_t length() const { return length_; }
43 46
(...skipping 10 matching lines...) Expand all
54 void OnUrlDownloaderStarted( 57 void OnUrlDownloaderStarted(
55 std::unique_ptr<DownloadCreateInfo> create_info, 58 std::unique_ptr<DownloadCreateInfo> create_info,
56 std::unique_ptr<ByteStreamReader> stream_reader, 59 std::unique_ptr<ByteStreamReader> stream_reader,
57 const DownloadUrlParameters::OnStartedCallback& callback) override; 60 const DownloadUrlParameters::OnStartedCallback& callback) override;
58 void OnUrlDownloaderStopped(UrlDownloader* downloader) override; 61 void OnUrlDownloaderStopped(UrlDownloader* downloader) override;
59 62
60 void AddUrlDownloader( 63 void AddUrlDownloader(
61 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> 64 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
62 downloader); 65 downloader);
63 66
64 DownloadWorker::Delegate* delegate_; 67 DownloadWorker::Delegate* const delegate_;
65 68
66 // The starting position of the content for this worker to download. 69 // The starting position of the content for this worker to download.
67 int64_t offset_; 70 int64_t offset_;
68 71
69 // The length of the request. May be 0 to fetch to the end of the file. 72 // The length of the request. May be 0 to fetch to the end of the file.
70 int64_t length_; 73 int64_t length_;
71 74
72 // Used to control the network request. Live on UI thread. 75 // Used to control the network request. Live on UI thread.
73 std::unique_ptr<DownloadRequestHandleInterface> request_handle_; 76 std::unique_ptr<DownloadRequestHandleInterface> request_handle_;
74 77
75 // Used to handle the url request. Live and die on IO thread. 78 // Used to handle the url request. Live and die on IO thread.
76 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> 79 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
77 url_downloader_; 80 url_downloader_;
78 81
79 base::WeakPtrFactory<DownloadWorker> weak_factory_; 82 base::WeakPtrFactory<DownloadWorker> weak_factory_;
80 83
81 DISALLOW_COPY_AND_ASSIGN(DownloadWorker); 84 DISALLOW_COPY_AND_ASSIGN(DownloadWorker);
82 }; 85 };
83 86
84 } // namespace content 87 } // namespace content
85 88
86 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_ 89 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_job.cc ('k') | content/browser/download/download_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698