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

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

Issue 2537373004: [OfflinePages] Call NotifyInterrupted for pending requests (Closed)
Patch Set: 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 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..ea5745cb5e675bebd3304648daf988278889e642 100644
--- a/components/offline_pages/downloads/download_notifying_observer.cc
+++ b/components/offline_pages/downloads/download_notifying_observer.cc
@@ -47,17 +47,21 @@ void DownloadNotifyingObserver::OnAdded(const SavePageRequest& request) {
DCHECK(notifier_.get());
if (!IsVisibleInUI(request.client_id()))
return;
+
+ // Calling Progress ensures notification is created in lieu of specific
+ // Add/Create call.
notifier_->NotifyDownloadProgress(DownloadUIItem(request));
+
+ // Now we need to update the notification if it is not active/offlining.
+ 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 +83,18 @@ bool DownloadNotifyingObserver::IsVisibleInUI(const ClientId& page) {
base::IsValidGUID(page.id);
}
+// Calls the appropriate notifier method depending upon the state of the
+// request. For example, an AVAILABLE request is not active (aka, pending)
+// which the notifier understands as an Interrupted operation vs. one that
+// has Progress or is Paused.
+void DownloadNotifyingObserver::NotifyRequestStateChange(
+ 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