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

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

Issue 2689373003: Introduce ParallelDownloadJob. (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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/byte_stream.h"
13 #include "content/browser/download/download_request_handle.h"
14 #include "content/browser/download/url_downloader.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/download_interrupt_reasons.h"
qinmin 2017/02/27 21:54:46 nit: still need this here? or only the cc file?
xingliu 2017/02/27 23:53:26 Done.
17 #include "content/public/browser/download_url_parameters.h"
18
19 namespace content {
20
21 // Helper class used to send subsequent range requests to fetch slices of the
22 // file after handling response of the original non-range request.
23 // TODO(xingliu): we should consider to reuse this class for single connection
24 // download.
25 class DownloadWorker : public UrlDownloader::Delegate {
26 public:
27 DownloadWorker();
28 virtual ~DownloadWorker();
29
30 // Send network request to ask for a download.
31 void SendRequest(std::unique_ptr<DownloadUrlParameters> params);
32
33 // Download operations.
34 void Pause();
35 void Resume();
36 void Cancel();
37
38 private:
39 // UrlDownloader::Delegate implementation.
40 void OnUrlDownloaderStarted(
41 std::unique_ptr<DownloadCreateInfo> create_info,
42 std::unique_ptr<ByteStreamReader> stream_reader,
43 const DownloadUrlParameters::OnStartedCallback& callback) override;
44 void OnUrlDownloaderStopped(UrlDownloader* downloader) override;
45
46 void AddUrlDownloader(
47 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
48 downloader);
49
50 // Used to control the network request. Live on UI thread.
51 std::unique_ptr<DownloadRequestHandleInterface> request_handle_;
52
53 // Used to handle the url request. Live and die on IO thread.
54 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
55 url_downloader_;
56
57 base::WeakPtrFactory<DownloadWorker> weak_factory_;
58
59 DISALLOW_COPY_AND_ASSIGN(DownloadWorker);
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698