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 // Helper function to initiate a download request. This function initiates |
| 125 // the download using functionality provided by the |
| 126 // ResourceDispatcherHostImpl::BeginURLRequest function. The function returns |
| 127 // the result of the downoad operation. Please see the |
| 128 // DownloadInterruptReason enum for information on possible return values. |
| 129 static DownloadInterruptReason BeginDownloadRequest( |
| 130 std::unique_ptr<net::URLRequest> url_request, |
| 131 const Referrer& referrer, |
| 132 ResourceContext* resource_context, |
| 133 bool is_content_initiated, |
| 134 int render_process_id, |
| 135 int render_view_route_id, |
| 136 int render_frame_route_id, |
| 137 bool do_not_prompt_for_login); |
| 138 |
123 private: | 139 private: |
124 using DownloadSet = std::set<DownloadItem*>; | 140 using DownloadSet = std::set<DownloadItem*>; |
125 using DownloadMap = std::unordered_map<uint32_t, DownloadItemImpl*>; | 141 using DownloadMap = std::unordered_map<uint32_t, DownloadItemImpl*>; |
126 using DownloadGuidMap = std::unordered_map<std::string, DownloadItemImpl*>; | 142 using DownloadGuidMap = std::unordered_map<std::string, DownloadItemImpl*>; |
127 using DownloadItemImplVector = std::vector<DownloadItemImpl*>; | 143 using DownloadItemImplVector = std::vector<DownloadItemImpl*>; |
128 using DownloadRemover = base::Callback<bool(const DownloadItemImpl*)>; | 144 using DownloadRemover = base::Callback<bool(const DownloadItemImpl*)>; |
129 | 145 |
130 // For testing. | 146 // For testing. |
131 friend class DownloadManagerTest; | 147 friend class DownloadManagerTest; |
132 friend class DownloadTest; | 148 friend class DownloadTest; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 url_downloaders_; | 238 url_downloaders_; |
223 | 239 |
224 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; | 240 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; |
225 | 241 |
226 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 242 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
227 }; | 243 }; |
228 | 244 |
229 } // namespace content | 245 } // namespace content |
230 | 246 |
231 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 247 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
OLD | NEW |