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

Unified Diff: chrome/browser/android/offline_pages/background_loader_offliner.cc

Issue 2857063002: Add a way to send the resource percentage signal to the RC. (Closed)
Patch Set: CR feedback, fix unit test. Created 3 years, 7 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: chrome/browser/android/offline_pages/background_loader_offliner.cc
diff --git a/chrome/browser/android/offline_pages/background_loader_offliner.cc b/chrome/browser/android/offline_pages/background_loader_offliner.cc
index b2fc873f41f19a28d41c4e6e0346492aa7528c5c..6c51aa3c18e67398a2048db7b56c9411e8ae0e9d 100644
--- a/chrome/browser/android/offline_pages/background_loader_offliner.cc
+++ b/chrome/browser/android/offline_pages/background_loader_offliner.cc
@@ -238,6 +238,15 @@ bool BackgroundLoaderOffliner::HandleTimeout(int64_t request_id) {
return false;
}
+void BackgroundLoaderOffliner::ObserveResourceTracking(
+ const ResourceDataType type,
+ int64_t started_count,
+ int64_t completed_count) {
+ // Add the signal to extra data, and use for tracking.
+ if (type == ResourceDataType::IMAGE)
+ AddResourceSignal(type, started_count, completed_count);
+}
+
void BackgroundLoaderOffliner::MarkLoadStartTime() {
load_start_time_ = base::TimeTicks::Now();
}
@@ -493,6 +502,17 @@ void BackgroundLoaderOffliner::AddLoadingSignal(const char* signal_name) {
signal_data_.SetDouble(signal_name, delay);
}
+void BackgroundLoaderOffliner::AddResourceSignal(const ResourceDataType type,
+ int64_t started_count,
+ int64_t completed_count) {
+ double percentage = 100.0 * static_cast<double>(completed_count) /
+ static_cast<double>(started_count);
+ // TODO(petewil): Use actual signal type instead of hardcoding name to image.
+ signal_data_.SetDouble("ImagePercentage", percentage);
+ signal_data_.SetDouble("StartedImages", started_count);
+ signal_data_.SetDouble("CompletedImages", completed_count);
+}
+
} // namespace offline_pages
DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData);

Powered by Google App Engine
This is Rietveld 408576698