Chromium Code Reviews| 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 |