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

Side by Side Diff: content/browser/download/download_worker.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_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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/byte_stream.h" 12 #include "content/browser/byte_stream.h"
13 #include "content/browser/download/download_request_handle.h" 13 #include "content/browser/download/download_request_handle.h"
14 #include "content/browser/download/url_downloader.h" 14 #include "content/browser/download/url_downloader.h"
15 #include "content/common/content_export.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/download_url_parameters.h" 17 #include "content/public/browser/download_url_parameters.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 // Helper class used to send subsequent range requests to fetch slices of the 21 // Helper class used to send subsequent range requests to fetch slices of the
21 // file after handling response of the original non-range request. 22 // file after handling response of the original non-range request.
22 // TODO(xingliu): we should consider to reuse this class for single connection 23 // TODO(xingliu): we should consider to reuse this class for single connection
23 // download. 24 // download.
24 class DownloadWorker : public UrlDownloader::Delegate { 25 class CONTENT_EXPORT DownloadWorker : public UrlDownloader::Delegate {
25 public: 26 public:
26 class Delegate { 27 class Delegate {
27 public: 28 public:
28 // Called when the the byte stream is established after server response is 29 // Called when the the byte stream is established after server response is
29 // handled. The stream contains data starts from |offset| of the 30 // handled. The stream contains data starts from |offset| of the
30 // destination file. 31 // destination file.
31 virtual void OnByteStreamReady( 32 virtual void OnByteStreamReady(
32 DownloadWorker* worker, 33 DownloadWorker* worker,
33 std::unique_ptr<ByteStreamReader> stream_reader) = 0; 34 std::unique_ptr<ByteStreamReader> stream_reader) = 0;
34 // Called when there is an error caused by the server response. 35 // Called when there is an error caused by the server response.
35 virtual void OnServerResponseError(DownloadWorker* worker, 36 virtual void OnServerResponseError(DownloadWorker* worker,
36 DownloadInterruptReason reason) = 0; 37 DownloadInterruptReason reason) = 0;
38 virtual bool IsPaused() const = 0;
39 virtual bool IsCanceled() const = 0;
37 }; 40 };
38 41
39 DownloadWorker(DownloadWorker::Delegate* delegate, 42 DownloadWorker(DownloadWorker::Delegate* delegate,
40 int64_t offset, 43 int64_t offset,
41 int64_t length); 44 int64_t length);
42 virtual ~DownloadWorker(); 45 virtual ~DownloadWorker();
43 46
44 int64_t offset() const { return offset_; } 47 int64_t offset() const { return offset_; }
45 int64_t length() const { return length_; } 48 int64_t length() const { return length_; }
46 49
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 url_downloader_; 83 url_downloader_;
81 84
82 base::WeakPtrFactory<DownloadWorker> weak_factory_; 85 base::WeakPtrFactory<DownloadWorker> weak_factory_;
83 86
84 DISALLOW_COPY_AND_ASSIGN(DownloadWorker); 87 DISALLOW_COPY_AND_ASSIGN(DownloadWorker);
85 }; 88 };
86 89
87 } // namespace content 90 } // namespace content
88 91
89 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_ 92 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698