| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/offline_pages/core/downloads/download_notifying_observer.h" | 5 #include "components/offline_pages/core/downloads/download_notifying_observer.h" |
| 6 | 6 |
| 7 #include "components/offline_pages/core/background/request_coordinator.h" | 7 #include "components/offline_pages/core/background/request_coordinator.h" |
| 8 #include "components/offline_pages/core/background/save_page_request.h" | 8 #include "components/offline_pages/core/background/save_page_request.h" |
| 9 #include "components/offline_pages/core/client_policy_controller.h" | 9 #include "components/offline_pages/core/client_policy_controller.h" |
| 10 #include "components/offline_pages/core/downloads/download_ui_adapter.h" | 10 #include "components/offline_pages/core/downloads/download_ui_adapter.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void DownloadNotifyingObserver::OnChanged(const SavePageRequest& request) { | 60 void DownloadNotifyingObserver::OnChanged(const SavePageRequest& request) { |
| 61 DCHECK(notifier_.get()); | 61 DCHECK(notifier_.get()); |
| 62 if (!IsVisibleInUI(request.client_id())) | 62 if (!IsVisibleInUI(request.client_id())) |
| 63 return; | 63 return; |
| 64 NotifyRequestStateChange(request); | 64 NotifyRequestStateChange(request); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void DownloadNotifyingObserver::OnNetworkProgress( | 67 void DownloadNotifyingObserver::OnNetworkProgress( |
| 68 const SavePageRequest& request, | 68 const SavePageRequest& request, |
| 69 int64_t received_bytes) { | 69 int64_t received_bytes) { |
| 70 DownloadUIItem item(request); | 70 // TODO(dimich): Enable this back in M59. See bug 704049 for more info and |
| 71 item.download_progress_bytes = received_bytes; | 71 // what was temporarily (for M58) reverted. |
| 72 notifier_->NotifyDownloadProgress(item); | |
| 73 } | 72 } |
| 74 | 73 |
| 75 void DownloadNotifyingObserver::OnCompleted( | 74 void DownloadNotifyingObserver::OnCompleted( |
| 76 const SavePageRequest& request, | 75 const SavePageRequest& request, |
| 77 RequestCoordinator::BackgroundSavePageResult status) { | 76 RequestCoordinator::BackgroundSavePageResult status) { |
| 78 DCHECK(notifier_.get()); | 77 DCHECK(notifier_.get()); |
| 79 if (!IsVisibleInUI(request.client_id())) | 78 if (!IsVisibleInUI(request.client_id())) |
| 80 return; | 79 return; |
| 81 if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS) | 80 if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS) |
| 82 notifier_->NotifyDownloadSuccessful(DownloadUIItem(request)); | 81 notifier_->NotifyDownloadSuccessful(DownloadUIItem(request)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 99 const SavePageRequest& request) { | 98 const SavePageRequest& request) { |
| 100 if (request.request_state() == SavePageRequest::RequestState::PAUSED) | 99 if (request.request_state() == SavePageRequest::RequestState::PAUSED) |
| 101 notifier_->NotifyDownloadPaused(DownloadUIItem(request)); | 100 notifier_->NotifyDownloadPaused(DownloadUIItem(request)); |
| 102 else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE) | 101 else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE) |
| 103 notifier_->NotifyDownloadInterrupted(DownloadUIItem(request)); | 102 notifier_->NotifyDownloadInterrupted(DownloadUIItem(request)); |
| 104 else | 103 else |
| 105 notifier_->NotifyDownloadProgress(DownloadUIItem(request)); | 104 notifier_->NotifyDownloadProgress(DownloadUIItem(request)); |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace offline_pages | 107 } // namespace offline_pages |
| OLD | NEW |