| 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" |
| 11 #include "base/task/cancelable_task_tracker.h" | 11 #include "base/task/cancelable_task_tracker.h" |
| 12 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" | 12 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" |
| 13 | 13 |
| 14 class PrefService; | 14 class PrefService; |
| 15 class GURL; | 15 class GURL; |
| 16 namespace base { | 16 namespace base { |
| 17 class FilePath; | 17 class FilePath; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace dom_distiller { | 20 namespace dom_distiller { |
| 21 class DomDistillerService; | 21 class DomDistillerService; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // This string contains the directory name in which offline pages are saved. |
| 25 // The directory is located in the profile directory. |
| 26 extern const char kReadingListOfflineDirectory[]; |
| 27 |
| 24 // This class downloads and deletes offline versions of URLs using DOM distiller | 28 // This class downloads and deletes offline versions of URLs using DOM distiller |
| 25 // to fetch the page and simplify it. Only one item is downloaded or deleted at | 29 // to fetch the page and simplify it. Only one item is downloaded or deleted at |
| 26 // a time using a queue of tasks that are handled sequentially. Items (page + | 30 // a time using a queue of tasks that are handled sequentially. Items (page + |
| 27 // images) are saved to individual folders within an offline folder, using md5 | 31 // images) are saved to individual folders within an offline folder, using md5 |
| 28 // hashing to create unique file names. When a deletion is requested, all | 32 // hashing to create unique file names. When a deletion is requested, all |
| 29 // previous downloads for that URL are cancelled as they would be deleted. | 33 // previous downloads for that URL are cancelled as they would be deleted. |
| 30 class URLDownloader { | 34 class URLDownloader { |
| 31 friend class MockURLDownloader; | 35 friend class MockURLDownloader; |
| 32 | 36 |
| 33 public: | 37 public: |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 std::deque<Task> tasks_; | 147 std::deque<Task> tasks_; |
| 144 bool working_; | 148 bool working_; |
| 145 base::FilePath base_directory_; | 149 base::FilePath base_directory_; |
| 146 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; | 150 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; |
| 147 base::CancelableTaskTracker task_tracker_; | 151 base::CancelableTaskTracker task_tracker_; |
| 148 | 152 |
| 149 DISALLOW_COPY_AND_ASSIGN(URLDownloader); | 153 DISALLOW_COPY_AND_ASSIGN(URLDownloader); |
| 150 }; | 154 }; |
| 151 | 155 |
| 152 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 156 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
| OLD | NEW |