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

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

Issue 2703773002: [IOS Reading List] Change handling of distillation error. (Closed)
Patch Set: feedback Created 3 years, 10 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
« no previous file with comments | « no previous file | ios/chrome/browser/reading_list/url_downloader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7b9c4f5901d12c4124b2354d5eb0ca4d56b397cc..e44d1a7de458133952ddf49635eb76efa33f8f6c 100644
--- a/ios/chrome/browser/reading_list/reading_list_download_service.cc
+++ b/ios/chrome/browser/reading_list/reading_list_download_service.cc
@@ -235,43 +235,46 @@ void ReadingListDownloadService::OnDownloadEnd(
const base::FilePath& distilled_path,
const std::string& title) {
DCHECK(reading_list_model_->loaded());
- if ((success == URLDownloader::DOWNLOAD_SUCCESS ||
- success == URLDownloader::DOWNLOAD_EXISTS) &&
- !distilled_path.empty()) {
- reading_list_model_->SetEntryDistilledInfo(url, distilled_path,
- distilled_url);
-
- std::string trimmed_title = base::CollapseWhitespaceASCII(title, false);
- if (!trimmed_title.empty())
- reading_list_model_->SetEntryTitle(url, trimmed_title);
-
- const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url);
- if (entry)
- UMA_HISTOGRAM_COUNTS_100("ReadingList.Download.Failures",
- entry->FailedDownloadCounter());
- UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", SUCCESS,
- STATUS_MAX);
-
- } else if (success == URLDownloader::ERROR_RETRY) {
- reading_list_model_->SetEntryDistilledState(url,
- ReadingListEntry::WILL_RETRY);
- ScheduleDownloadEntry(url);
-
- const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url);
- if (entry) {
- if (entry->FailedDownloadCounter() < kNumberOfFailsBeforeStop) {
+ URLDownloader::SuccessState real_success_value = success;
+ if (distilled_path.empty()) {
+ real_success_value = URLDownloader::ERROR;
+ }
+ switch (real_success_value) {
+ case URLDownloader::DOWNLOAD_SUCCESS:
+ case URLDownloader::DOWNLOAD_EXISTS: {
+ reading_list_model_->SetEntryDistilledInfo(url, distilled_path,
+ distilled_url);
+
+ std::string trimmed_title = base::CollapseWhitespaceASCII(title, false);
+ if (!trimmed_title.empty())
+ reading_list_model_->SetEntryTitle(url, trimmed_title);
+
+ const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url);
+ if (entry)
+ UMA_HISTOGRAM_COUNTS_100("ReadingList.Download.Failures",
+ entry->FailedDownloadCounter());
+ UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", SUCCESS,
+ STATUS_MAX);
+ break;
+ }
+ case URLDownloader::ERROR: {
+ const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url);
+ // Add this failure to the total failure count.
+ if (entry &&
+ entry->FailedDownloadCounter() + 1 < kNumberOfFailsBeforeStop) {
+ reading_list_model_->SetEntryDistilledState(
+ url, ReadingListEntry::WILL_RETRY);
+ ScheduleDownloadEntry(url);
UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", RETRY,
STATUS_MAX);
} else {
UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", FAILURE,
STATUS_MAX);
+ reading_list_model_->SetEntryDistilledState(url,
+ ReadingListEntry::ERROR);
}
+ break;
}
-
- } else if (success == URLDownloader::ERROR_PERMANENT) {
- reading_list_model_->SetEntryDistilledState(url, ReadingListEntry::ERROR);
- UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", FAILURE,
- STATUS_MAX);
}
}
« no previous file with comments | « no previous file | ios/chrome/browser/reading_list/url_downloader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698