Chromium Code Reviews| 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 { | 25 namespace reading_list { |
| 26 class ReadingListDistillerPageFactory; | 26 class ReadingListDistillerPageFactory; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Observes the reading list and downloads offline versions of its articles. | 29 // Observes the reading list and downloads offline versions of its articles. |
| 30 // Any calls made to DownloadAllEntries/DownloadEntry before the model is | 30 // Any calls made to DownloadAllEntries/DownloadEntry before the model is |
|
gambard
2017/01/25 09:02:07
Update this comment.
Olivier
2017/01/25 12:25:30
SyncWithModel is private. Removed from comment.
| |
| 31 // 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 |
|
gambard
2017/01/25 09:02:07
Same
Olivier
2017/01/25 12:25:30
Done.
| |
| 32 // called automatically. | 32 // called automatically. |
| 33 class ReadingListDownloadService | 33 class ReadingListDownloadService |
| 34 : public KeyedService, | 34 : public KeyedService, |
| 35 public ReadingListModelObserver, | 35 public ReadingListModelObserver, |
| 36 public net::NetworkChangeNotifier::ConnectionTypeObserver { | 36 public net::NetworkChangeNotifier::ConnectionTypeObserver { |
| 37 public: | 37 public: |
| 38 ReadingListDownloadService( | 38 ReadingListDownloadService( |
| 39 ReadingListModel* reading_list_model, | 39 ReadingListModel* reading_list_model, |
| 40 dom_distiller::DomDistillerService* distiller_service, | 40 dom_distiller::DomDistillerService* distiller_service, |
| 41 PrefService* prefs, | 41 PrefService* prefs, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 58 void ReadingListModelLoaded(const ReadingListModel* model) override; | 58 void ReadingListModelLoaded(const ReadingListModel* model) override; |
| 59 void ReadingListWillRemoveEntry(const ReadingListModel* model, | 59 void ReadingListWillRemoveEntry(const ReadingListModel* model, |
| 60 const GURL& url) override; | 60 const GURL& url) override; |
| 61 void ReadingListDidAddEntry(const ReadingListModel* model, | 61 void ReadingListDidAddEntry(const ReadingListModel* model, |
| 62 const GURL& url, | 62 const GURL& url, |
| 63 reading_list::EntrySource entry_source) override; | 63 reading_list::EntrySource entry_source) override; |
| 64 void ReadingListDidMoveEntry(const ReadingListModel* model, | 64 void ReadingListDidMoveEntry(const ReadingListModel* model, |
| 65 const GURL& url) override; | 65 const GURL& url) override; |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 // Tries to save offline versions of all entries in the reading list that are | 68 // Checks the model and determine what entries are processed and what entries |
|
jif
2017/01/25 09:15:51
s/what entries/which entries/
jif
2017/01/25 09:15:51
s/determine/determines/
Olivier
2017/01/25 12:25:30
Done.
Olivier
2017/01/25 12:25:30
Done.
| |
| 69 // not yet saved. Must only be called after reading list model is loaded. | 69 // needs to be processed. |
|
jif
2017/01/25 09:15:51
need
Olivier
2017/01/25 12:25:31
Done.
| |
| 70 void DownloadAllEntries(); | 70 // Initiates a cleanup of |OfflineRoot| directory removing sub_directories |
|
gambard
2017/01/25 09:02:07
s/OfflineRoot/OfflineRoot()/
Olivier
2017/01/25 12:25:31
Done.
| |
| 71 // not corresponding to a processed ReadingListEntry. | |
| 72 // Schedule unprocessed entries for distillation. | |
| 73 void SyncWithModel(); | |
| 74 // Scans |OfflineRoot| directory and deletes all subdirectories not listed in | |
|
gambard
2017/01/25 09:02:07
s/OfflineRoot/OfflineRoot()/
Olivier
2017/01/25 12:25:30
Done.
| |
| 75 // processed_directories. | |
|
gambard
2017/01/25 09:02:07
s/processed_directories/|processed_directories|/
Olivier
2017/01/25 12:25:31
Done.
| |
| 76 // Must be called on File thread. | |
| 77 void CleanUpFiles(const std::set<std::string>& processed_directories); | |
|
gambard
2017/01/25 09:02:07
Based on the name of the function I would expect i
Olivier
2017/01/25 12:25:30
Done.
| |
| 78 // Schedules all emtries in |unprocessed_entries| for distillation. | |
|
gambard
2017/01/25 09:02:07
s/emtries/entries/
This sentence looks weird to me
Olivier
2017/01/25 12:25:31
Done.
| |
| 79 void DownloadUnprocessedEntries(const std::set<GURL>& unprocessed_entries); | |
| 71 // Processes a new entry and schedule a download if needed. | 80 // Processes a new entry and schedule a download if needed. |
|
gambard
2017/01/25 09:02:07
s/schedule/schedules
Olivier
2017/01/25 12:25:31
Done.
| |
| 72 void ProcessNewEntry(const GURL& url); | 81 void ProcessNewEntry(const GURL& url); |
| 73 // Schedule a download of an offline version of the reading list entry, | 82 // Schedules a download of an offline version of the reading list entry, |
| 74 // according to the delay of the entry. Must only be called after reading list | 83 // according to the delay of the entry. Must only be called after reading list |
| 75 // model is loaded. | 84 // model is loaded. |
| 76 void ScheduleDownloadEntry(const GURL& url); | 85 void ScheduleDownloadEntry(const GURL& url); |
| 77 // Tries to save an offline version of the reading list entry if it is not yet | 86 // Tries to save an offline version of the reading list entry if it is not yet |
| 78 // saved. Must only be called after reading list model is loaded. | 87 // saved. Must only be called after reading list model is loaded. |
| 79 void DownloadEntry(const GURL& url); | 88 void DownloadEntry(const GURL& url); |
| 80 // Removes the offline version of the reading list entry if it exists. Must | 89 // Removes the offline version of the reading list entry if it exists. Must |
| 81 // only be called after reading list model is loaded. | 90 // only be called after reading list model is loaded. |
| 82 void RemoveDownloadedEntry(const GURL& url); | 91 void RemoveDownloadedEntry(const GURL& url); |
| 83 // Callback for entry download. | 92 // Callback for entry download. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 102 bool had_connection_; | 111 bool had_connection_; |
| 103 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> | 112 std::unique_ptr<reading_list::ReadingListDistillerPageFactory> |
| 104 distiller_page_factory_; | 113 distiller_page_factory_; |
| 105 | 114 |
| 106 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_; | 115 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_; |
| 107 | 116 |
| 108 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService); | 117 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService); |
| 109 }; | 118 }; |
| 110 | 119 |
| 111 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ | 120 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ |
| OLD | NEW |