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

Unified Diff: components/offline_pages/downloads/download_notifying_observer.cc

Issue 2521353005: [OfflinePages] Call NotifyInterrupted for pending requests (Closed)
Patch Set: Fix indeterminate progress bar for Downloading... Created 4 years, 1 month 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: components/offline_pages/downloads/download_notifying_observer.cc
diff --git a/components/offline_pages/downloads/download_notifying_observer.cc b/components/offline_pages/downloads/download_notifying_observer.cc
index 397bcc975a867fbd9fff675cb620921857ca9662..025a3c2dbd51e64cac2f350e0c4112f3480df4d2 100644
--- a/components/offline_pages/downloads/download_notifying_observer.cc
+++ b/components/offline_pages/downloads/download_notifying_observer.cc
@@ -47,17 +47,23 @@ void DownloadNotifyingObserver::OnAdded(const SavePageRequest& request) {
DCHECK(notifier_.get());
if (!IsVisibleInUI(request.client_id()))
return;
+
+ // There is no Added call for the notifier so we perform a Progress call
fgorski 2016/11/29 17:50:59 nit: how about: Calling Progress ensures notificat
dougarnett 2016/11/29 20:43:30 Done.
+ // to cause the notification to be created.
notifier_->NotifyDownloadProgress(DownloadUIItem(request));
+
+ // Now we need to update the notification if it is not active/offlining.
+ // TODO(dougarnett): Handle request state in notifier impl so this call
fgorski 2016/11/29 17:50:59 Why? If we do so, it will require double call for
dougarnett 2016/11/29 20:43:30 Removed TODO. The concern here was if we experienc
+ // is not needed.
+ if (request.request_state() != SavePageRequest::RequestState::OFFLINING)
+ NotifyRequestStateChange(request);
}
void DownloadNotifyingObserver::OnChanged(const SavePageRequest& request) {
DCHECK(notifier_.get());
if (!IsVisibleInUI(request.client_id()))
return;
- if (request.request_state() == SavePageRequest::RequestState::PAUSED)
- notifier_->NotifyDownloadPaused(DownloadUIItem(request));
- else
- notifier_->NotifyDownloadProgress(DownloadUIItem(request));
+ NotifyRequestStateChange(request);
}
void DownloadNotifyingObserver::OnCompleted(
@@ -79,4 +85,14 @@ bool DownloadNotifyingObserver::IsVisibleInUI(const ClientId& page) {
base::IsValidGUID(page.id);
}
+void DownloadNotifyingObserver::NotifyRequestStateChange(
fgorski 2016/11/29 17:50:59 Thanks for extracting this one. I think the overal
dougarnett 2016/11/29 20:43:30 Acknowledged.
+ const SavePageRequest& request) {
+ if (request.request_state() == SavePageRequest::RequestState::PAUSED)
+ notifier_->NotifyDownloadPaused(DownloadUIItem(request));
+ else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE)
+ notifier_->NotifyDownloadInterrupted(DownloadUIItem(request));
+ else
+ notifier_->NotifyDownloadProgress(DownloadUIItem(request));
+}
+
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698