| 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_READING_LIST_DOWNLOAD_SERVICE_H_ | 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ |
| 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ | 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/keyed_service/core/keyed_service.h" | 9 #include "components/keyed_service/core/keyed_service.h" |
| 10 #include "components/reading_list/ios/reading_list_model_observer.h" | 10 #include "components/reading_list/ios/reading_list_model_observer.h" |
| 11 #include "ios/chrome/browser/reading_list/url_downloader.h" | 11 #include "ios/chrome/browser/reading_list/url_downloader.h" |
| 12 #include "net/base/network_change_notifier.h" | 12 #include "net/base/network_change_notifier.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 class PrefService; | 15 class PrefService; |
| 16 class ReadingListModel; | 16 class ReadingListModel; |
| 17 namespace base { | 17 namespace base { |
| 18 class FilePath; | 18 class FilePath; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace dom_distiller { | |
| 22 class DomDistillerService; | |
| 23 } | |
| 24 | |
| 25 namespace reading_list { | 21 namespace reading_list { |
| 26 class ReadingListDistillerPageFactory; | 22 class ReadingListDistillerPageFactory; |
| 27 } | 23 } |
| 28 | 24 |
| 29 // Observes the reading list and downloads offline versions of its articles. | 25 // Observes the reading list and downloads offline versions of its articles. |
| 30 // Any calls made to DownloadEntry before the model is loaded will be ignored. | 26 // Any calls made to DownloadEntry before the model is loaded will be ignored. |
| 31 // When the model is loaded, offline directory is automatically synced with the | 27 // When the model is loaded, offline directory is automatically synced with the |
| 32 // entries in the model. | 28 // entries in the model. |
| 33 class ReadingListDownloadService | 29 class ReadingListDownloadService |
| 34 : public KeyedService, | 30 : public KeyedService, |
| 35 public ReadingListModelObserver, | 31 public ReadingListModelObserver, |
| 36 public net::NetworkChangeNotifier::ConnectionTypeObserver { | 32 public net::NetworkChangeNotifier::ConnectionTypeObserver { |
| 37 public: | 33 public: |
| 38 ReadingListDownloadService( | 34 ReadingListDownloadService( |
| 39 ReadingListModel* reading_list_model, | 35 ReadingListModel* reading_list_model, |
| 40 dom_distiller::DomDistillerService* distiller_service, | |
| 41 PrefService* prefs, | 36 PrefService* prefs, |
| 42 base::FilePath chrome_profile_path, | 37 base::FilePath chrome_profile_path, |
| 43 net::URLRequestContextGetter* url_request_context_getter, | 38 net::URLRequestContextGetter* url_request_context_getter, |
| 39 std::unique_ptr<dom_distiller::DistillerFactory> distiller_factory, |
| 44 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> | 40 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> |
| 45 distiller_page_factory); | 41 distiller_page_factory); |
| 46 ~ReadingListDownloadService() override; | 42 ~ReadingListDownloadService() override; |
| 47 | 43 |
| 48 // Initializes the reading list download service. | 44 // Initializes the reading list download service. |
| 49 void Initialize(); | 45 void Initialize(); |
| 50 | 46 |
| 51 // The root folder containing all the offline files. | 47 // The root folder containing all the offline files. |
| 52 virtual base::FilePath OfflineRoot() const; | 48 virtual base::FilePath OfflineRoot() const; |
| 53 | 49 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 net::NetworkChangeNotifier::ConnectionType type) override; | 100 net::NetworkChangeNotifier::ConnectionType type) override; |
| 105 | 101 |
| 106 ReadingListModel* reading_list_model_; | 102 ReadingListModel* reading_list_model_; |
| 107 base::FilePath chrome_profile_path_; | 103 base::FilePath chrome_profile_path_; |
| 108 std::unique_ptr<URLDownloader> url_downloader_; | 104 std::unique_ptr<URLDownloader> url_downloader_; |
| 109 std::vector<GURL> url_to_download_cellular_; | 105 std::vector<GURL> url_to_download_cellular_; |
| 110 std::vector<GURL> url_to_download_wifi_; | 106 std::vector<GURL> url_to_download_wifi_; |
| 111 bool had_connection_; | 107 bool had_connection_; |
| 112 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> | 108 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> |
| 113 distiller_page_factory_; | 109 distiller_page_factory_; |
| 110 std::unique_ptr<dom_distiller::DistillerFactory> distiller_factory_; |
| 114 | 111 |
| 115 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_; | 112 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_; |
| 116 | 113 |
| 117 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService); | 114 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService); |
| 118 }; | 115 }; |
| 119 | 116 |
| 120 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ | 117 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ |
| OLD | NEW |