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

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

Issue 2736843002: Fix the Download Notifications for Offline Pages to indicate bytes loaded. (Closed)
Patch Set: more fixes to more tests. 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 f729bc51c35847bd78afb582e0817cc89fbc4f80..cc80a3424d2d6ade6e83c8a159104717fdc12ca0 100644
--- a/components/offline_pages/core/background/request_coordinator.cc
+++ b/components/offline_pages/core/background/request_coordinator.cc
@@ -883,6 +883,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) {
@@ -934,6 +936,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) {
@@ -1066,6 +1076,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