Commit 6195222c authored by Carlos Knippschild's avatar Carlos Knippschild Committed by Commit Bot

Adds missing OfflinePage downloads metrics reporting

This change also splits the reporting of offline page counts between
prefetched and non-prefetched.

Bug: 896095, 894643
Change-Id: Ic3bfc53ecd2558df1b349af66bbe7d3f88bd6531
Reviewed-on: https://chromium-review.googlesource.com/c/1285750Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Carlos Knippschild <carlosk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601015}
parent 01e6b4ad
......@@ -1128,6 +1128,15 @@ public class DownloadUtils {
return item.getDownloadInfo().getLastAccessTime() != 0;
}
/**
* Returns |true| if the offline item is not null and has already been viewed by the user.
* @param offlineItem The offline item to check.
* @return true if the item is valid has been viewed by the user.
*/
public static boolean isOfflineItemViewed(OfflineItem offlineItem) {
return offlineItem != null && offlineItem.lastAccessedTimeMs > offlineItem.completionTimeMs;
}
/**
* Given two timestamps, calculates if both occur on the same date.
* @return True if they belong in the same day. False otherwise.
......
......@@ -36,7 +36,6 @@ import org.chromium.components.download.DownloadState;
import org.chromium.components.offline_items_collection.ContentId;
import org.chromium.components.offline_items_collection.OfflineContentProvider;
import org.chromium.components.offline_items_collection.OfflineItem;
import org.chromium.components.offline_items_collection.OfflineItemFilter;
import org.chromium.components.offline_items_collection.OfflineItemState;
import org.chromium.components.variations.VariationsAssociatedData;
......@@ -817,17 +816,34 @@ public class DownloadHistoryAdapter
}
private void recordOfflineItemCountHistograms() {
int[] itemCounts = new int[OfflineItemFilter.FILTER_BOUNDARY];
for (DownloadHistoryItemWrapper item : mOfflineItems) {
OfflineItemWrapper offlineItem = (OfflineItemWrapper) item;
if (offlineItem.isOffTheRecord()) continue;
itemCounts[offlineItem.getOfflineItemFilter()]++;
int offlinePageCount = 0;
int viewedOfflinePageCount = 0;
int prefetchedOfflinePageCount = 0;
int viewedPrefetchedOfflinePageCount = 0;
for (DownloadHistoryItemWrapper itemWrapper : mOfflineItems) {
if (itemWrapper.isOffTheRecord()) continue;
OfflineItemWrapper offlineItemWrapper = (OfflineItemWrapper) itemWrapper;
boolean hasBeenViewed = DownloadUtils.isOfflineItemViewed(offlineItemWrapper.getItem());
if (offlineItemWrapper.isSuggested()) {
prefetchedOfflinePageCount++;
if (hasBeenViewed) viewedPrefetchedOfflinePageCount++;
} else {
offlinePageCount++;
if (hasBeenViewed) viewedOfflinePageCount++;
}
}
// TODO(shaktisahu): UMA for initial counts of offline pages, regular downloads and download
// file types and file extensions.
RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.OfflinePage",
itemCounts[OfflineItemFilter.FILTER_PAGE]);
RecordHistogram.recordCountHistogram(
"Android.DownloadManager.InitialCount.OfflinePage", offlinePageCount);
RecordHistogram.recordCountHistogram(
"Android.DownloadManager.InitialCount.Viewed.OfflinePage", viewedOfflinePageCount);
RecordHistogram.recordCountHistogram(
"Android.DownloadManager.InitialCount.PrefetchedOfflinePage",
prefetchedOfflinePageCount);
RecordHistogram.recordCountHistogram(
"Android.DownloadManager.InitialCount.Viewed.PrefetchedOfflinePage",
viewedPrefetchedOfflinePageCount);
}
@Override
......
......@@ -122847,6 +122847,7 @@ uploading your change for review.
<suffix name="Image"/>
<suffix name="OfflinePage"/>
<suffix name="Other"/>
<suffix name="PrefetchedOfflinePage"/>
<suffix name="Total"/>
<suffix name="Video"/>
<affected-histogram name="Android.DownloadManager.InitialCount"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment