| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 void GetAllDownloads(DownloadVector* result) override; | 71 void GetAllDownloads(DownloadVector* result) override; |
| 72 void StartDownload( | 72 void StartDownload( |
| 73 std::unique_ptr<DownloadCreateInfo> info, | 73 std::unique_ptr<DownloadCreateInfo> info, |
| 74 std::unique_ptr<ByteStreamReader> stream, | 74 std::unique_ptr<ByteStreamReader> stream, |
| 75 const DownloadUrlParameters::OnStartedCallback& on_started) override; | 75 const DownloadUrlParameters::OnStartedCallback& on_started) override; |
| 76 | 76 |
| 77 int RemoveDownloadsByURLAndTime( | 77 int RemoveDownloadsByURLAndTime( |
| 78 const base::Callback<bool(const GURL&)>& url_filter, | 78 const base::Callback<bool(const GURL&)>& url_filter, |
| 79 base::Time remove_begin, | 79 base::Time remove_begin, |
| 80 base::Time remove_end) override; | 80 base::Time remove_end) override; |
| 81 int RemoveAllDownloads() override; | |
| 82 void DownloadUrl(std::unique_ptr<DownloadUrlParameters> params) override; | 81 void DownloadUrl(std::unique_ptr<DownloadUrlParameters> params) override; |
| 83 void AddObserver(Observer* observer) override; | 82 void AddObserver(Observer* observer) override; |
| 84 void RemoveObserver(Observer* observer) override; | 83 void RemoveObserver(Observer* observer) override; |
| 85 content::DownloadItem* CreateDownloadItem( | 84 content::DownloadItem* CreateDownloadItem( |
| 86 const std::string& guid, | 85 const std::string& guid, |
| 87 uint32_t id, | 86 uint32_t id, |
| 88 const base::FilePath& current_path, | 87 const base::FilePath& current_path, |
| 89 const base::FilePath& target_path, | 88 const base::FilePath& target_path, |
| 90 const std::vector<GURL>& url_chain, | 89 const std::vector<GURL>& url_chain, |
| 91 const GURL& referrer_url, | 90 const GURL& referrer_url, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 bool is_content_initiated, | 132 bool is_content_initiated, |
| 134 int render_process_id, | 133 int render_process_id, |
| 135 int render_view_route_id, | 134 int render_view_route_id, |
| 136 int render_frame_route_id, | 135 int render_frame_route_id, |
| 137 bool do_not_prompt_for_login); | 136 bool do_not_prompt_for_login); |
| 138 | 137 |
| 139 private: | 138 private: |
| 140 using DownloadSet = std::set<DownloadItem*>; | 139 using DownloadSet = std::set<DownloadItem*>; |
| 141 using DownloadGuidMap = std::unordered_map<std::string, DownloadItemImpl*>; | 140 using DownloadGuidMap = std::unordered_map<std::string, DownloadItemImpl*>; |
| 142 using DownloadItemImplVector = std::vector<DownloadItemImpl*>; | 141 using DownloadItemImplVector = std::vector<DownloadItemImpl*>; |
| 143 using DownloadRemover = base::Callback<bool(const DownloadItemImpl*)>; | |
| 144 | 142 |
| 145 // For testing. | 143 // For testing. |
| 146 friend class DownloadManagerTest; | 144 friend class DownloadManagerTest; |
| 147 friend class DownloadTest; | 145 friend class DownloadTest; |
| 148 | 146 |
| 149 void StartDownloadWithId( | 147 void StartDownloadWithId( |
| 150 std::unique_ptr<DownloadCreateInfo> info, | 148 std::unique_ptr<DownloadCreateInfo> info, |
| 151 std::unique_ptr<ByteStreamReader> stream, | 149 std::unique_ptr<ByteStreamReader> stream, |
| 152 const DownloadUrlParameters::OnStartedCallback& on_started, | 150 const DownloadUrlParameters::OnStartedCallback& on_started, |
| 153 bool new_download, | 151 bool new_download, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 168 | 166 |
| 169 // Get next download id. |callback| is called on the UI thread and may | 167 // Get next download id. |callback| is called on the UI thread and may |
| 170 // be called synchronously. | 168 // be called synchronously. |
| 171 void GetNextId(const DownloadIdCallback& callback); | 169 void GetNextId(const DownloadIdCallback& callback); |
| 172 | 170 |
| 173 // Called with the result of DownloadManagerDelegate::CheckForFileExistence. | 171 // Called with the result of DownloadManagerDelegate::CheckForFileExistence. |
| 174 // Updates the state of the file and then notifies this update to the file's | 172 // Updates the state of the file and then notifies this update to the file's |
| 175 // observer. | 173 // observer. |
| 176 void OnFileExistenceChecked(uint32_t download_id, bool result); | 174 void OnFileExistenceChecked(uint32_t download_id, bool result); |
| 177 | 175 |
| 178 // Remove all downloads for which |remover| returns true. | |
| 179 int RemoveDownloads(const DownloadRemover& remover); | |
| 180 | |
| 181 // Overridden from DownloadItemImplDelegate | 176 // Overridden from DownloadItemImplDelegate |
| 182 // (Note that |GetBrowserContext| are present in both interfaces.) | 177 // (Note that |GetBrowserContext| are present in both interfaces.) |
| 183 void DetermineDownloadTarget(DownloadItemImpl* item, | 178 void DetermineDownloadTarget(DownloadItemImpl* item, |
| 184 const DownloadTargetCallback& callback) override; | 179 const DownloadTargetCallback& callback) override; |
| 185 bool ShouldCompleteDownload(DownloadItemImpl* item, | 180 bool ShouldCompleteDownload(DownloadItemImpl* item, |
| 186 const base::Closure& complete_callback) override; | 181 const base::Closure& complete_callback) override; |
| 187 bool ShouldOpenFileBasedOnExtension(const base::FilePath& path) override; | 182 bool ShouldOpenFileBasedOnExtension(const base::FilePath& path) override; |
| 188 bool ShouldOpenDownload(DownloadItemImpl* item, | 183 bool ShouldOpenDownload(DownloadItemImpl* item, |
| 189 const ShouldOpenDownloadCallback& callback) override; | 184 const ShouldOpenDownloadCallback& callback) override; |
| 190 void CheckForFileRemoval(DownloadItemImpl* download_item) override; | 185 void CheckForFileRemoval(DownloadItemImpl* download_item) override; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 url_downloaders_; | 233 url_downloaders_; |
| 239 | 234 |
| 240 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; | 235 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; |
| 241 | 236 |
| 242 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 237 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
| 243 }; | 238 }; |
| 244 | 239 |
| 245 } // namespace content | 240 } // namespace content |
| 246 | 241 |
| 247 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 242 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
| OLD | NEW |