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

Unified Diff: components/offline_pages/core/background/request_coordinator.cc

Issue 2742833004: Fix the Download Notifications for Offline Pages to indicate bytes loaded. (Closed)
Patch Set: Created 3 years, 9 months 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/core/background/request_coordinator.cc
diff --git a/components/offline_pages/core/background/request_coordinator.cc b/components/offline_pages/core/background/request_coordinator.cc
index 5a363c0a8b056e1a7edc003e0180e37577d5891b..1c07552f3515e3cbea87fce1b40566f243048c7a 100644
--- a/components/offline_pages/core/background/request_coordinator.cc
+++ b/components/offline_pages/core/background/request_coordinator.cc
@@ -848,6 +848,8 @@ void RequestCoordinator::StartOffliner(
if (offliner_->LoadAndSave(
update_result->updated_items.at(0),
base::Bind(&RequestCoordinator::OfflinerDoneCallback,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&RequestCoordinator::OfflinerProgressCallback,
weak_ptr_factory_.GetWeakPtr()))) {
base::TimeDelta timeout;
if (processing_state_ == ProcessingWindowState::SCHEDULED_WINDOW) {
@@ -899,6 +901,14 @@ void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request,
scheduler_callback_.Run(true);
}
+void RequestCoordinator::OfflinerProgressCallback(
+ const SavePageRequest& request,
+ int64_t received_bytes) {
+ DVLOG(2) << "offliner progress, received bytes: " << received_bytes;
+ DCHECK(received_bytes >= 0);
+ NotifyNetworkProgress(request, received_bytes);
+}
+
void RequestCoordinator::UpdateRequestForCompletedAttempt(
const SavePageRequest& request,
Offliner::RequestStatus status) {
@@ -1031,6 +1041,12 @@ void RequestCoordinator::NotifyChanged(const SavePageRequest& request) {
observer.OnChanged(request);
}
+void RequestCoordinator::NotifyNetworkProgress(const SavePageRequest& request,
+ int64_t received_bytes) {
+ for (Observer& observer : observers_)
+ observer.OnNetworkProgress(request, received_bytes);
+}
+
ClientPolicyController* RequestCoordinator::GetPolicyController() {
return policy_controller_.get();
}

Powered by Google App Engine
This is Rietveld 408576698