OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
6 #define IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 6 #define IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 URLDownloader(dom_distiller::DomDistillerService* distiller_service, | 61 URLDownloader(dom_distiller::DomDistillerService* distiller_service, |
62 PrefService* prefs, | 62 PrefService* prefs, |
63 base::FilePath chrome_profile_path, | 63 base::FilePath chrome_profile_path, |
64 const DownloadCompletion& download_completion, | 64 const DownloadCompletion& download_completion, |
65 const SuccessCompletion& delete_completion); | 65 const SuccessCompletion& delete_completion); |
66 virtual ~URLDownloader(); | 66 virtual ~URLDownloader(); |
67 | 67 |
68 // Asynchronously download an offline version of the URL. | 68 // Asynchronously download an offline version of the URL. |
69 void DownloadOfflineURL(const GURL& url); | 69 void DownloadOfflineURL(const GURL& url); |
70 | 70 |
| 71 // Cancels the download job an offline version of the URL. |
| 72 void CancelDownloadOfflineURL(const GURL& url); |
| 73 |
71 // Asynchronously remove the offline version of the URL if it exists. | 74 // Asynchronously remove the offline version of the URL if it exists. |
72 void RemoveOfflineURL(const GURL& url); | 75 void RemoveOfflineURL(const GURL& url); |
73 | 76 |
74 private: | 77 private: |
75 enum TaskType { DELETE, DOWNLOAD }; | 78 enum TaskType { DELETE, DOWNLOAD }; |
76 using Task = std::pair<TaskType, GURL>; | 79 using Task = std::pair<TaskType, GURL>; |
77 | 80 |
78 // Calls callback with true if an offline file exists for this URL. | 81 // Calls callback with true if an offline file exists for this URL. |
79 void OfflineURLExists(const GURL& url, base::Callback<void(bool)> callback); | 82 void OfflineURLExists(const GURL& url, base::Callback<void(bool)> callback); |
80 // Handles the next task in the queue, if no task is currently being handled. | 83 // Handles the next task in the queue, if no task is currently being handled. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 std::deque<Task> tasks_; | 132 std::deque<Task> tasks_; |
130 bool working_; | 133 bool working_; |
131 base::FilePath base_directory_; | 134 base::FilePath base_directory_; |
132 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; | 135 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; |
133 base::CancelableTaskTracker task_tracker_; | 136 base::CancelableTaskTracker task_tracker_; |
134 | 137 |
135 DISALLOW_COPY_AND_ASSIGN(URLDownloader); | 138 DISALLOW_COPY_AND_ASSIGN(URLDownloader); |
136 }; | 139 }; |
137 | 140 |
138 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 141 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
OLD | NEW |