| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 // Cancels the download job an offline version of the URL. | 91 // Cancels the download job an offline version of the URL. |
| 92 void CancelDownloadOfflineURL(const GURL& url); | 92 void CancelDownloadOfflineURL(const GURL& url); |
| 93 | 93 |
| 94 // Asynchronously remove the offline version of the URL if it exists. | 94 // Asynchronously remove the offline version of the URL if it exists. |
| 95 void RemoveOfflineURL(const GURL& url); | 95 void RemoveOfflineURL(const GURL& url); |
| 96 | 96 |
| 97 // URLFetcherDelegate delegate method. | 97 // URLFetcherDelegate delegate method. |
| 98 void OnURLFetchComplete(const net::URLFetcher* source) override; | 98 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 99 | 99 |
| 100 // Cancels the current download task. |
| 101 void CancelTask(); |
| 102 |
| 100 private: | 103 private: |
| 101 enum TaskType { DELETE, DOWNLOAD }; | 104 enum TaskType { DELETE, DOWNLOAD }; |
| 102 using Task = std::pair<TaskType, GURL>; | 105 using Task = std::pair<TaskType, GURL>; |
| 103 | 106 |
| 104 // Calls callback with true if an offline path exists. |path| must be | 107 // Calls callback with true if an offline path exists. |path| must be |
| 105 // absolute. | 108 // absolute. |
| 106 void OfflinePathExists(const base::FilePath& url, | 109 void OfflinePathExists(const base::FilePath& url, |
| 107 base::Callback<void(bool)> callback); | 110 base::Callback<void(bool)> callback); |
| 108 // Handles the next task in the queue, if no task is currently being handled. | 111 // Handles the next task in the queue, if no task is currently being handled. |
| 109 void HandleNextTask(); | 112 void HandleNextTask(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 std::unique_ptr<net::URLFetcher> fetcher_; | 191 std::unique_ptr<net::URLFetcher> fetcher_; |
| 189 // URLRequestContextGetter needed for the URLFetcher. | 192 // URLRequestContextGetter needed for the URLFetcher. |
| 190 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 193 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 191 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; | 194 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; |
| 192 base::CancelableTaskTracker task_tracker_; | 195 base::CancelableTaskTracker task_tracker_; |
| 193 | 196 |
| 194 DISALLOW_COPY_AND_ASSIGN(URLDownloader); | 197 DISALLOW_COPY_AND_ASSIGN(URLDownloader); |
| 195 }; | 198 }; |
| 196 | 199 |
| 197 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 200 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
| OLD | NEW |