Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_download_service.h

Issue 2525663002: Refactor Reading List Model to use URL as key. (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 28 matching lines...) Expand all
39 ~ReadingListDownloadService() override; 39 ~ReadingListDownloadService() override;
40 40
41 // Initializes the reading list download service. 41 // Initializes the reading list download service.
42 void Initialize(); 42 void Initialize();
43 43
44 // KeyedService implementation. 44 // KeyedService implementation.
45 void Shutdown() override; 45 void Shutdown() override;
46 46
47 // ReadingListModelObserver implementation 47 // ReadingListModelObserver implementation
48 void ReadingListModelLoaded(const ReadingListModel* model) override; 48 void ReadingListModelLoaded(const ReadingListModel* model) override;
49 void ReadingListWillRemoveReadEntry(const ReadingListModel* model, 49 void ReadingListWillRemoveEntry(const ReadingListModel* model,
50 size_t index) override; 50 const GURL& url) override;
51 void ReadingListWillRemoveUnreadEntry(const ReadingListModel* model, 51 void ReadingListDidAddEntry(const ReadingListModel* model,
52 size_t index) override; 52 const GURL& url) override;
53 void ReadingListWillAddUnreadEntry(const ReadingListModel* model,
54 const ReadingListEntry& entry) override;
55 void ReadingListWillAddReadEntry(const ReadingListModel* model,
56 const ReadingListEntry& entry) override;
57 53
58 private: 54 private:
59 // Tries to save offline versions of all entries in the reading list that are 55 // Tries to save offline versions of all entries in the reading list that are
60 // not yet saved. Must only be called after reading list model is loaded. 56 // not yet saved. Must only be called after reading list model is loaded.
61 void DownloadAllEntries(); 57 void DownloadAllEntries();
62 // Schedule a download of an offline version of the reading list entry, 58 // Schedule a download of an offline version of the reading list entry,
63 // according to the delay of the entry. Must only be called after reading list 59 // according to the delay of the entry. Must only be called after reading list
64 // model is loaded. 60 // model is loaded.
65 void ScheduleDownloadEntry(const ReadingListEntry& entry); 61 void ScheduleDownloadEntry(const GURL& url);
66 // Tries to save an offline version of the reading list entry corresponding to
67 // the |url| if it is not yet saved. Must only be called after reading list
68 // model is loaded.
69 void DownloadEntryFromURL(const GURL& url);
70 // Schedule a download of an offline version of the reading list entry
71 // associated to this |url|, according to the delay of the entry. Must only be
72 // called after reading list model is loaded.
73 void ScheduleDownloadEntryFromURL(const GURL& url);
74 // Tries to save an offline version of the reading list entry if it is not yet 62 // Tries to save an offline version of the reading list entry if it is not yet
75 // saved. Must only be called after reading list model is loaded. 63 // saved. Must only be called after reading list model is loaded.
76 void DownloadEntry(const ReadingListEntry& entry); 64 void DownloadEntry(const GURL& url);
77 // Removes the offline version of the reading list entry if it exists. Must 65 // Removes the offline version of the reading list entry if it exists. Must
78 // only be called after reading list model is loaded. 66 // only be called after reading list model is loaded.
79 void RemoveDownloadedEntry(const ReadingListEntry& entry); 67 void RemoveDownloadedEntry(const GURL& url);
80 // Callback for entry download. 68 // Callback for entry download.
81 void OnDownloadEnd(const GURL& url, 69 void OnDownloadEnd(const GURL& url,
82 URLDownloader::SuccessState success, 70 URLDownloader::SuccessState success,
83 const base::FilePath& distilled_path, 71 const base::FilePath& distilled_path,
84 const std::string& title); 72 const std::string& title);
85 73
86 // Callback for entry deletion. 74 // Callback for entry deletion.
87 void OnDeleteEnd(const GURL& url, bool success); 75 void OnDeleteEnd(const GURL& url, bool success);
88 76
89 // net::NetworkChangeNotifier::ConnectionTypeObserver: 77 // net::NetworkChangeNotifier::ConnectionTypeObserver:
90 void OnConnectionTypeChanged( 78 void OnConnectionTypeChanged(
91 net::NetworkChangeNotifier::ConnectionType type) override; 79 net::NetworkChangeNotifier::ConnectionType type) override;
92 80
93 ReadingListModel* reading_list_model_; 81 ReadingListModel* reading_list_model_;
94 std::unique_ptr<URLDownloader> url_downloader_; 82 std::unique_ptr<URLDownloader> url_downloader_;
95 std::vector<GURL> url_to_download_cellular_; 83 std::vector<GURL> url_to_download_cellular_;
96 std::vector<GURL> url_to_download_wifi_; 84 std::vector<GURL> url_to_download_wifi_;
97 bool had_connection_; 85 bool had_connection_;
98 86
99 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_; 87 base::WeakPtrFactory<ReadingListDownloadService> weak_ptr_factory_;
100 88
101 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService); 89 DISALLOW_COPY_AND_ASSIGN(ReadingListDownloadService);
102 }; 90 };
103 91
104 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_ 92 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DOWNLOAD_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698