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

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

Issue 2689373003: Introduce ParallelDownloadJob. (Closed)
Patch Set: nits. 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_url_parameters.h"
17
18 namespace content {
19
20 // 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 // TODO(xingliu): we should consider to reuse this class for single connection
23 // download.
24 class DownloadWorker : public UrlDownloader::Delegate {
25 public:
26 DownloadWorker();
27 virtual ~DownloadWorker();
28
29 // Send network request to ask for a download.
30 void SendRequest(std::unique_ptr<DownloadUrlParameters> params);
31
32 // Download operations.
33 void Pause();
34 void Resume();
35 void Cancel();
36
37 private:
38 // UrlDownloader::Delegate implementation.
39 void OnUrlDownloaderStarted(
40 std::unique_ptr<DownloadCreateInfo> create_info,
41 std::unique_ptr<ByteStreamReader> stream_reader,
42 const DownloadUrlParameters::OnStartedCallback& callback) override;
43 void OnUrlDownloaderStopped(UrlDownloader* downloader) override;
44
45 void AddUrlDownloader(
46 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
47 downloader);
48
49 // Used to control the network request. Live on UI thread.
50 std::unique_ptr<DownloadRequestHandleInterface> request_handle_;
51
52 // Used to handle the url request. Live and die on IO thread.
53 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
54 url_downloader_;
55
56 base::WeakPtrFactory<DownloadWorker> weak_factory_;
57
58 DISALLOW_COPY_AND_ASSIGN(DownloadWorker);
59 };
60
61 } // namespace content
62
63 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_WORKER_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_request_core.cc ('k') | content/browser/download/download_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698