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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 NotifyRequestStateChange(request); | 57 NotifyRequestStateChange(request); |
58 } | 58 } |
59 | 59 |
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( |
| 68 const SavePageRequest& request, |
| 69 int64_t received_bytes) { |
| 70 DownloadUIItem item(request); |
| 71 item.download_progress_bytes = received_bytes; |
| 72 notifier_->NotifyDownloadProgress(item); |
| 73 } |
| 74 |
67 void DownloadNotifyingObserver::OnCompleted( | 75 void DownloadNotifyingObserver::OnCompleted( |
68 const SavePageRequest& request, | 76 const SavePageRequest& request, |
69 RequestCoordinator::BackgroundSavePageResult status) { | 77 RequestCoordinator::BackgroundSavePageResult status) { |
70 DCHECK(notifier_.get()); | 78 DCHECK(notifier_.get()); |
71 if (!IsVisibleInUI(request.client_id())) | 79 if (!IsVisibleInUI(request.client_id())) |
72 return; | 80 return; |
73 if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS) | 81 if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS) |
74 notifier_->NotifyDownloadSuccessful(DownloadUIItem(request)); | 82 notifier_->NotifyDownloadSuccessful(DownloadUIItem(request)); |
75 else if (status == RequestCoordinator::BackgroundSavePageResult::REMOVED) | 83 else if (status == RequestCoordinator::BackgroundSavePageResult::REMOVED) |
76 notifier_->NotifyDownloadCanceled(DownloadUIItem(request)); | 84 notifier_->NotifyDownloadCanceled(DownloadUIItem(request)); |
(...skipping 14 matching lines...) Expand all Loading... |
91 const SavePageRequest& request) { | 99 const SavePageRequest& request) { |
92 if (request.request_state() == SavePageRequest::RequestState::PAUSED) | 100 if (request.request_state() == SavePageRequest::RequestState::PAUSED) |
93 notifier_->NotifyDownloadPaused(DownloadUIItem(request)); | 101 notifier_->NotifyDownloadPaused(DownloadUIItem(request)); |
94 else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE) | 102 else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE) |
95 notifier_->NotifyDownloadInterrupted(DownloadUIItem(request)); | 103 notifier_->NotifyDownloadInterrupted(DownloadUIItem(request)); |
96 else | 104 else |
97 notifier_->NotifyDownloadProgress(DownloadUIItem(request)); | 105 notifier_->NotifyDownloadProgress(DownloadUIItem(request)); |
98 } | 106 } |
99 | 107 |
100 } // namespace offline_pages | 108 } // namespace offline_pages |
OLD | NEW |