OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_URL_DOWNLOADER_H_ | |
6 #define CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ | |
7 | |
8 #include "base/memory/linked_ptr.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "content/browser/loader/resource_handler.h" | |
11 #include "content/public/browser/download_save_info.h" | |
12 #include "content/public/browser/download_url_parameters.h" | |
13 #include "content/public/common/referrer.h" | |
14 #include "net/url_request/url_request.h" | |
15 | |
16 namespace content { | |
17 class DownloadManager; | |
18 class ResourceContext; | |
19 | |
20 class UrlDownloader : public net::URLRequest::Delegate { | |
21 public: | |
22 UrlDownloader(scoped_ptr<net::URLRequest> request, | |
23 scoped_ptr<ResourceHandler> handler); | |
24 ~UrlDownloader() override; | |
25 | |
26 static DownloadInterruptReason BeginDownload( | |
27 DownloadManager* download_manager, | |
28 scoped_ptr<net::URLRequest> request, | |
29 const Referrer& referrer, | |
30 bool is_content_initiated, | |
31 ResourceContext* context, | |
32 bool prefer_cache, | |
33 bool do_not_prompt_for_login, | |
34 scoped_ptr<DownloadSaveInfo> save_info, | |
35 uint32 download_id, | |
36 const DownloadUrlParameters::OnStartedCallback& started_callback); | |
37 | |
38 void OnResponseStarted(net::URLRequest* request) override; | |
asanka
2015/11/20 19:57:46
Add a comment noting that this is the URLRequest::
svaldez
2015/11/23 15:18:57
Done.
| |
39 | |
40 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | |
asanka
2015/11/20 19:57:46
We should also deal with OnReceivedRedirect() and
svaldez
2015/11/23 15:18:57
Done.
| |
41 | |
42 void ResponseCompleted(); | |
43 void StartReading(bool is_continuation); | |
44 | |
45 void Start(); | |
46 | |
47 private: | |
48 scoped_ptr<net::URLRequest> request_; | |
49 scoped_ptr<ResourceHandler> handler_; | |
50 | |
51 base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_; | |
52 }; | |
53 | |
54 namespace { | |
55 static std::vector<linked_ptr<content::UrlDownloader>> g_active_downloaders; | |
56 } | |
57 | |
58 } // namespace content | |
59 | |
60 #endif // CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ | |
OLD | NEW |