| 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 { | 21 namespace dom_distiller { |
| 22 class DomDistillerService; | 22 class DomDistillerService; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace reading_list { |
| 26 class ReadingListDistillerPageFactory; |
| 27 } |
| 28 |
| 25 // Observes the reading list and downloads offline versions of its articles. | 29 // Observes the reading list and downloads offline versions of its articles. |
| 26 // Any calls made to DownloadAllEntries/DownloadEntry before the model is | 30 // Any calls made to DownloadAllEntries/DownloadEntry before the model is |
| 27 // loaded will be ignored. When the model is loaded, DownloadAllEntries will be | 31 // loaded will be ignored. When the model is loaded, DownloadAllEntries will be |
| 28 // called automatically. | 32 // called automatically. |
| 29 class ReadingListDownloadService | 33 class ReadingListDownloadService |
| 30 : public KeyedService, | 34 : public KeyedService, |
| 31 public ReadingListModelObserver, | 35 public ReadingListModelObserver, |
| 32 public net::NetworkChangeNotifier::ConnectionTypeObserver { | 36 public net::NetworkChangeNotifier::ConnectionTypeObserver { |
| 33 public: | 37 public: |
| 34 ReadingListDownloadService( | 38 ReadingListDownloadService( |
| 35 ReadingListModel* reading_list_model, | 39 ReadingListModel* reading_list_model, |
| 36 dom_distiller::DomDistillerService* distiller_service, | 40 dom_distiller::DomDistillerService* distiller_service, |
| 37 PrefService* prefs, | 41 PrefService* prefs, |
| 38 base::FilePath chrome_profile_path); | 42 base::FilePath chrome_profile_path, |
| 43 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> |
| 44 distiller_page_factory); |
| 39 ~ReadingListDownloadService() override; | 45 ~ReadingListDownloadService() override; |
| 40 | 46 |
| 41 // Initializes the reading list download service. | 47 // Initializes the reading list download service. |
| 42 void Initialize(); | 48 void Initialize(); |
| 43 | 49 |
| 44 // The root folder containing all the offline files. | 50 // The root folder containing all the offline files. |
| 45 virtual base::FilePath OfflineRoot() const; | 51 virtual base::FilePath OfflineRoot() const; |
| 46 | 52 |
| 47 // KeyedService implementation. | 53 // KeyedService implementation. |
| 48 void Shutdown() override; | 54 void Shutdown() override; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // net::NetworkChangeNotifier::ConnectionTypeObserver: | 90 // net::NetworkChangeNotifier::ConnectionTypeObserver: |
| 85 void OnConnectionTypeChanged( | 91 void OnConnectionTypeChanged( |
| 86 net::NetworkChangeNotifier::ConnectionType type) override; | 92 net::NetworkChangeNotifier::ConnectionType type) override; |
| 87 | 93 |
| 88 ReadingListModel* reading_list_model_; | 94 ReadingListModel* reading_list_model_; |
| 89 base::FilePath chrome_profile_path_; | 95 base::FilePath chrome_profile_path_; |
| 90 std::unique_ptr<URLDownloader> url_downloader_; | 96 std::unique_ptr<URLDownloader> url_downloader_; |
| 91 std::vector<GURL> url_to_download_cellular_; | 97 std::vector<GURL> url_to_download_cellular_; |
| 92 std::vector<GURL> url_to_download_wifi_; | 98 std::vector<GURL> url_to_download_wifi_; |
| 93 bool had_connection_; | 99 bool had_connection_; |
| 100 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> |
| 101 distiller_page_factory_; |
| 94 | 102 |
| 95 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_; | 103 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_; |
| 96 | 104 |
| 97 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService); | 105 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService); |
| 98 }; | 106 }; |
| 99 | 107 |
| 100 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ | 108 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ |
| OLD | NEW |