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

Unified Diff: ios/chrome/browser/reading_list/reading_list_download_service.cc

Issue 2320403002: Update reading list entry on download (Closed)
Patch Set: address comments Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/reading_list/reading_list_download_service.cc
diff --git a/ios/chrome/browser/reading_list/reading_list_download_service.cc b/ios/chrome/browser/reading_list/reading_list_download_service.cc
index fe510d5f25a637796e4ce5ca59b3e76916b92304..61b1d01d93ab416efa3555a6323f1b9990ee0d29 100644
--- a/ios/chrome/browser/reading_list/reading_list_download_service.cc
+++ b/ios/chrome/browser/reading_list/reading_list_download_service.cc
@@ -10,7 +10,6 @@
#include "base/files/file_path.h"
#include "ios/chrome/browser/reading_list/reading_list_entry.h"
#include "ios/chrome/browser/reading_list/reading_list_model.h"
-#include "ios/chrome/browser/reading_list/url_downloader.h"
ReadingListDownloadService::ReadingListDownloadService(
ReadingListModel* reading_list_model,
@@ -87,7 +86,11 @@ void ReadingListDownloadService::DownloadAllEntries() {
void ReadingListDownloadService::DownloadEntry(const ReadingListEntry& entry) {
DCHECK(reading_list_model_->loaded());
- url_downloader_->DownloadOfflineURL(entry.URL());
+ if (entry.DistilledState() != ReadingListEntry::ERROR) {
+ reading_list_model_->SetEntryDistilledState(entry.URL(),
+ ReadingListEntry::PROCESSING);
+ url_downloader_->DownloadOfflineURL(entry.URL());
+ }
}
void ReadingListDownloadService::RemoveDownloadedEntry(
@@ -96,10 +99,24 @@ void ReadingListDownloadService::RemoveDownloadedEntry(
url_downloader_->RemoveOfflineURL(entry.URL());
}
-void ReadingListDownloadService::OnDownloadEnd(const GURL& url, bool success) {
- // TODO(crbug.com/616747) update entry with offline info
+void ReadingListDownloadService::OnDownloadEnd(
+ const GURL& url,
+ URLDownloader::SuccessState success,
+ const GURL& distilled_url,
+ const std::string& title) {
+ DCHECK(reading_list_model_->loaded());
+ if ((success == URLDownloader::DOWNLOAD_SUCCESS ||
+ success == URLDownloader::DOWNLOAD_EXISTS) &&
+ distilled_url.is_valid()) {
+ reading_list_model_->SetEntryDistilledURL(url, distilled_url);
+ } else if (success == URLDownloader::ERROR_RETRY) {
+ reading_list_model_->SetEntryDistilledState(url,
+ ReadingListEntry::WILL_RETRY);
+ } else if (success == URLDownloader::ERROR_PERMANENT) {
+ reading_list_model_->SetEntryDistilledState(url, ReadingListEntry::ERROR);
+ }
}
void ReadingListDownloadService::OnDeleteEnd(const GURL& url, bool success) {
- // TODO(crbug.com/616747) update entry with offline info
+ // Nothing to update as this is only called when deleting reading list entries
}

Powered by Google App Engine
This is Rietveld 408576698