OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace net { | 31 namespace net { |
32 class BoundNetLog; | 32 class BoundNetLog; |
33 } | 33 } |
34 | 34 |
35 namespace content { | 35 namespace content { |
36 class DownloadFileFactory; | 36 class DownloadFileFactory; |
37 class DownloadItemFactory; | 37 class DownloadItemFactory; |
38 class DownloadItemImpl; | 38 class DownloadItemImpl; |
39 class DownloadRequestHandleInterface; | 39 class DownloadRequestHandleInterface; |
| 40 class ResourceContext; |
40 | 41 |
41 class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager, | 42 class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager, |
42 private DownloadItemImplDelegate { | 43 private DownloadItemImplDelegate { |
43 public: | 44 public: |
44 using DownloadItemImplCreated = base::Callback<void(DownloadItemImpl*)>; | 45 using DownloadItemImplCreated = base::Callback<void(DownloadItemImpl*)>; |
45 | 46 |
46 // Caller guarantees that |net_log| will remain valid | 47 // Caller guarantees that |net_log| will remain valid |
47 // for the lifetime of DownloadManagerImpl (until Shutdown() is called). | 48 // for the lifetime of DownloadManagerImpl (until Shutdown() is called). |
48 DownloadManagerImpl(net::NetLog* net_log, BrowserContext* browser_context); | 49 DownloadManagerImpl(net::NetLog* net_log, BrowserContext* browser_context); |
49 ~DownloadManagerImpl() override; | 50 ~DownloadManagerImpl() override; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 114 |
114 // For testing; specifically, accessed from TestFileErrorInjector. | 115 // For testing; specifically, accessed from TestFileErrorInjector. |
115 void SetDownloadItemFactoryForTesting( | 116 void SetDownloadItemFactoryForTesting( |
116 std::unique_ptr<DownloadItemFactory> item_factory); | 117 std::unique_ptr<DownloadItemFactory> item_factory); |
117 void SetDownloadFileFactoryForTesting( | 118 void SetDownloadFileFactoryForTesting( |
118 std::unique_ptr<DownloadFileFactory> file_factory); | 119 std::unique_ptr<DownloadFileFactory> file_factory); |
119 virtual DownloadFileFactory* GetDownloadFileFactoryForTesting(); | 120 virtual DownloadFileFactory* GetDownloadFileFactoryForTesting(); |
120 | 121 |
121 void RemoveUrlDownloader(UrlDownloader* downloader); | 122 void RemoveUrlDownloader(UrlDownloader* downloader); |
122 | 123 |
| 124 // Invoked when the RDH is created. |
| 125 static void ResourceDispatcherHostCreated(); |
| 126 |
| 127 // Helper function to initiate a download request. This function initiates |
| 128 // the download using functionality provided by the |
| 129 // ResourceDispatcherHostImpl::BeginURLRequest function. The function returns |
| 130 // the result of the downoad operation. Please see the |
| 131 // DownloadInterruptReason enum for information on possible return values. |
| 132 static DownloadInterruptReason BeginDownloadRequest( |
| 133 std::unique_ptr<net::URLRequest> url_request, |
| 134 const Referrer& referrer, |
| 135 ResourceContext* resource_context, |
| 136 bool is_content_initiated, |
| 137 int render_process_id, |
| 138 int render_view_route_id, |
| 139 int render_frame_route_id, |
| 140 bool do_not_prompt_for_login); |
| 141 |
123 private: | 142 private: |
124 using DownloadSet = std::set<DownloadItem*>; | 143 using DownloadSet = std::set<DownloadItem*>; |
125 using DownloadMap = std::unordered_map<uint32_t, DownloadItemImpl*>; | 144 using DownloadMap = std::unordered_map<uint32_t, DownloadItemImpl*>; |
126 using DownloadGuidMap = std::unordered_map<std::string, DownloadItemImpl*>; | 145 using DownloadGuidMap = std::unordered_map<std::string, DownloadItemImpl*>; |
127 using DownloadItemImplVector = std::vector<DownloadItemImpl*>; | 146 using DownloadItemImplVector = std::vector<DownloadItemImpl*>; |
128 using DownloadRemover = base::Callback<bool(const DownloadItemImpl*)>; | 147 using DownloadRemover = base::Callback<bool(const DownloadItemImpl*)>; |
129 | 148 |
130 // For testing. | 149 // For testing. |
131 friend class DownloadManagerTest; | 150 friend class DownloadManagerTest; |
132 friend class DownloadTest; | 151 friend class DownloadTest; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 url_downloaders_; | 241 url_downloaders_; |
223 | 242 |
224 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; | 243 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; |
225 | 244 |
226 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 245 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
227 }; | 246 }; |
228 | 247 |
229 } // namespace content | 248 } // namespace content |
230 | 249 |
231 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 250 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
OLD | NEW |