Commit d891a23f authored by twellington's avatar twellington Committed by Commit bot

Fix a download histograms

Record opening downloads in CCT and fix histogram for download counts.

BUG=657542, 657539

Review-Url: https://codereview.chromium.org/2443623002
Cr-Commit-Position: refs/heads/master@{#427167}
parent c1846906
...@@ -135,9 +135,9 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo ...@@ -135,9 +135,9 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
} }
} }
if (!isOffTheRecord) recordDownloadCountHistograms(mItemCounts, result.size()); if (!isOffTheRecord) recordDownloadCountHistograms(mItemCounts);
if (mLoadingDelegate.isLoaded()) filter(mLoadingDelegate.getPendingFilter()); onItemsRetrieved();
} }
/** Called when the user's offline page history has been gathered. */ /** Called when the user's offline page history has been gathered. */
...@@ -153,10 +153,20 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo ...@@ -153,10 +153,20 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
mFilePathsToItemsMap.addItem(wrapper); mFilePathsToItemsMap.addItem(wrapper);
} }
if (mLoadingDelegate.isLoaded()) filter(mLoadingDelegate.getPendingFilter());
RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.OfflinePage", RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.OfflinePage",
result.size()); result.size());
onItemsRetrieved();
}
/**
* Should be called when download items or offline pages have been retrieved.
*/
private void onItemsRetrieved() {
if (mLoadingDelegate.isLoaded()) {
recordTotalDownloadCountHistogram();
filter(mLoadingDelegate.getPendingFilter());
}
} }
/** Returns the total size of all non-deleted downloaded items. */ /** Returns the total size of all non-deleted downloaded items. */
...@@ -439,7 +449,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo ...@@ -439,7 +449,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
return new OfflinePageItemWrapper(item, mBackendProvider, mParentComponent); return new OfflinePageItemWrapper(item, mBackendProvider, mParentComponent);
} }
private void recordDownloadCountHistograms(int[] itemCounts, int totalCount) { private void recordDownloadCountHistograms(int[] itemCounts) {
RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Audio", RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Audio",
itemCounts[DownloadFilter.FILTER_AUDIO]); itemCounts[DownloadFilter.FILTER_AUDIO]);
RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Document", RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Document",
...@@ -450,8 +460,13 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo ...@@ -450,8 +460,13 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
itemCounts[DownloadFilter.FILTER_OTHER]); itemCounts[DownloadFilter.FILTER_OTHER]);
RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Video", RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Video",
itemCounts[DownloadFilter.FILTER_VIDEO]); itemCounts[DownloadFilter.FILTER_VIDEO]);
}
private void recordTotalDownloadCountHistogram() {
// The total count intentionally leaves out incognito downloads. This should be revisited
// if/when incognito downloads are persistently available in downloads home.
RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Total", RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Total",
totalCount); mDownloadItems.size() + mOfflinePageItems.size());
} }
private void removeExternallyDeletedItem(DownloadItemWrapper wrapper, boolean isOffTheRecord) { private void removeExternallyDeletedItem(DownloadItemWrapper wrapper, boolean isOffTheRecord) {
......
...@@ -190,6 +190,7 @@ public abstract class DownloadHistoryItemWrapper implements TimedItem { ...@@ -190,6 +190,7 @@ public abstract class DownloadHistoryItemWrapper implements TimedItem {
Intent intent = DownloadUtils.getMediaViewerIntentForDownloadItem( Intent intent = DownloadUtils.getMediaViewerIntentForDownloadItem(
fileUri, shareUri, mimeType); fileUri, shareUri, mimeType);
IntentHandler.startActivityForTrustedIntent(intent, context); IntentHandler.startActivityForTrustedIntent(intent, context);
recordOpenSuccess();
return; return;
} }
......
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