Commit 45fe917c authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Cleanup MobileDownload.Background histogram

Remove code and mark histograms as obsolete.

Bug: 1123581
Change-Id: I66fabee84ecab2a40a45a25d85ed31a4a92798a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442900Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814431}
parent 6547d8f8
......@@ -191,10 +191,6 @@ public class DownloadBroadcastManager extends Service {
DownloadNotificationUmaHelper.recordDownloadResumptionHistogram(browserStarted
? UmaDownloadResumption.BROWSER_RUNNING
: UmaDownloadResumption.BROWSER_NOT_RUNNING);
if (!browserStarted) {
DownloadManagerService.getDownloadManagerService()
.onBackgroundDownloadStarted(id.id);
}
}
DownloadStartupUtils.ensureDownloadSystemInitialized(
......
......@@ -35,9 +35,7 @@ import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadManagerBridge.DownloadEnqueueRequest;
import org.chromium.chrome.browser.download.DownloadManagerBridge.DownloadEnqueueResponse;
import org.chromium.chrome.browser.download.DownloadNotificationUmaHelper.UmaBackgroundDownload;
import org.chromium.chrome.browser.download.DownloadNotificationUmaHelper.UmaDownloadResumption;
import org.chromium.chrome.browser.download.items.OfflineContentAggregatorFactory;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
......@@ -57,12 +55,9 @@ import org.chromium.components.feature_engagement.Tracker;
import org.chromium.components.offline_items_collection.ContentId;
import org.chromium.components.offline_items_collection.FailState;
import org.chromium.components.offline_items_collection.LegacyHelpers;
import org.chromium.components.offline_items_collection.OfflineContentProvider;
import org.chromium.components.offline_items_collection.OfflineItem;
import org.chromium.components.offline_items_collection.OfflineItemSchedule;
import org.chromium.components.offline_items_collection.OfflineItemState;
import org.chromium.components.offline_items_collection.PendingState;
import org.chromium.components.offline_items_collection.UpdateDelta;
import org.chromium.components.prefs.PrefService;
import org.chromium.components.user_prefs.UserPrefs;
import org.chromium.content_public.browser.BrowserStartupController;
......@@ -101,7 +96,6 @@ public class DownloadManagerService implements DownloadController.Observer,
public static final long UNKNOWN_BYTES_RECEIVED = -1;
private static final Set<String> sFirstSeenDownloadIds = new HashSet<String>();
private static final Set<String> sBackgroundDownloadIds = new HashSet<String>();
private static DownloadManagerService sDownloadManagerService;
private static boolean sIsNetworkListenerDisabled;
......@@ -198,44 +192,6 @@ public class DownloadManagerService implements DownloadController.Observer,
}
}
private class BackgroundDownloadUmaRecorder implements OfflineContentProvider.Observer {
BackgroundDownloadUmaRecorder() {
OfflineContentAggregatorFactory.get().addObserver(this);
}
@Override
public void onItemUpdated(OfflineItem item, UpdateDelta updateDelta) {
if (!LegacyHelpers.isLegacyDownload(item.id)) return;
switch (item.state) {
case OfflineItemState.COMPLETE:
maybeRecordBackgroundDownload(UmaBackgroundDownload.COMPLETED, item.id.id);
break;
case OfflineItemState.CANCELLED:
maybeRecordBackgroundDownload(UmaBackgroundDownload.CANCELLED, item.id.id);
break;
case OfflineItemState.INTERRUPTED:
maybeRecordBackgroundDownload(UmaBackgroundDownload.INTERRUPTED, item.id.id);
break;
case OfflineItemState.FAILED:
maybeRecordBackgroundDownload(UmaBackgroundDownload.FAILED, item.id.id);
break;
case OfflineItemState.PENDING:
case OfflineItemState.PAUSED:
case OfflineItemState.IN_PROGRESS:
default:
break;
}
}
@Override
public void onItemsAdded(ArrayList<OfflineItem> items) {}
@Override
public void onItemRemoved(ContentId id) {}
}
private BackgroundDownloadUmaRecorder mBackgroundDownloadUmaRecorder;
/**
* Creates DownloadManagerService.
*/
......@@ -385,16 +341,10 @@ public class DownloadManagerService implements DownloadController.Observer,
DownloadItem item = new DownloadItem(false, downloadInfo);
if (!downloadInfo.isResumable()) {
status = DownloadStatus.FAILED;
maybeRecordBackgroundDownload(
UmaBackgroundDownload.FAILED, downloadInfo.getDownloadGuid());
} else if (isAutoResumable) {
addAutoResumableDownload(item.getId());
}
if (status == DownloadStatus.INTERRUPTED) {
maybeRecordBackgroundDownload(
UmaBackgroundDownload.INTERRUPTED, downloadInfo.getDownloadGuid());
}
updateDownloadProgress(item, status);
updateDownloadInfoBar(item);
......@@ -608,16 +558,12 @@ public class DownloadManagerService implements DownloadController.Observer,
mDownloadNotifier.notifyDownloadSuccessful(
info, item.getSystemDownloadId(), result.second, isSupportedMimeType);
broadcastDownloadSuccessful(info);
maybeRecordBackgroundDownload(
UmaBackgroundDownload.COMPLETED, info.getDownloadGuid());
} else {
info = DownloadInfo.Builder.fromDownloadInfo(info)
.setFailState(FailState.CANNOT_DOWNLOAD)
.build();
mDownloadNotifier.notifyDownloadFailed(info);
// TODO(qinmin): get the failure message from native.
maybeRecordBackgroundDownload(
UmaBackgroundDownload.FAILED, info.getDownloadGuid());
}
}
};
......@@ -1045,7 +991,6 @@ public class DownloadManagerService implements DownloadController.Observer,
DownloadInfoBarController infoBarController = getInfoBarController(isOffTheRecord);
if (infoBarController != null) infoBarController.onDownloadItemRemoved(id);
}
maybeRecordBackgroundDownload(UmaBackgroundDownload.CANCELLED, id.id);
}
/**
......@@ -1756,34 +1701,6 @@ public class DownloadManagerService implements DownloadController.Observer,
return mAutoResumptionLimit;
}
/**
* Called when a background download is started.
* @param downloadGuid Download GUID
*/
public void onBackgroundDownloadStarted(String downloadGuid) {
DownloadNotificationUmaHelper.recordBackgroundDownloadHistogram(
UmaBackgroundDownload.STARTED);
sBackgroundDownloadIds.add(downloadGuid);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_OFFLINE_CONTENT_PROVIDER)) {
mBackgroundDownloadUmaRecorder = new BackgroundDownloadUmaRecorder();
}
}
/**
* Record metrics for a download if it was started in background.
* @param event UmaBackgroundDownload event to log
* @param downloadGuid Download GUID
*/
private void maybeRecordBackgroundDownload(
@UmaBackgroundDownload int event, String downloadGuid) {
if (sBackgroundDownloadIds.contains(downloadGuid)) {
if (event != UmaBackgroundDownload.INTERRUPTED) {
sBackgroundDownloadIds.remove(downloadGuid);
}
DownloadNotificationUmaHelper.recordBackgroundDownloadHistogram(event);
}
}
/**
* Creates an interrupted download in native code to be used by instrumentation tests.
* @param url URL of the download.
......
......@@ -91,21 +91,6 @@ public final class DownloadNotificationUmaHelper {
int NUM_ENTRIES = 7;
}
// Values for the histograms MobileDownload.Background.*. Keep in sync with
// MobileDownloadBackgroundDownloadEvent in enums.xml.
@IntDef({UmaBackgroundDownload.STARTED, UmaBackgroundDownload.COMPLETED,
UmaBackgroundDownload.CANCELLED, UmaBackgroundDownload.FAILED,
UmaBackgroundDownload.INTERRUPTED})
@Retention(RetentionPolicy.SOURCE)
public @interface UmaBackgroundDownload {
int STARTED = 0;
int COMPLETED = 1;
int CANCELLED = 2;
int FAILED = 3;
int INTERRUPTED = 4;
int NUM_ENTRIES = 5;
}
/**
* Records an instance where a user interacts with a notification (clicks on, pauses, etc).
* @param action Notification interaction that was taken (ie. pause, resume).
......@@ -176,13 +161,4 @@ public final class DownloadNotificationUmaHelper {
RecordHistogram.recordEnumeratedHistogram(
"MobileDownload.DownloadResumption", type, UmaDownloadResumption.NUM_ENTRIES);
}
/**
* Helper method to record the background download resumption UMA.
* @param type UMA type to be recorded.
*/
static void recordBackgroundDownloadHistogram(@UmaBackgroundDownload int type) {
RecordHistogram.recordEnumeratedHistogram(
"MobileDownload.Background", type, UmaBackgroundDownload.NUM_ENTRIES);
}
}
......@@ -48609,6 +48609,9 @@ Called by update_use_counter_css.py.-->
</enum>
<enum name="MobileDownloadBackgroundDownloadEvent">
<obsolete>
Removed 2020-10.
</obsolete>
<int value="0" label="Started"/>
<int value="1" label="Completed"/>
<int value="2" label="Cancelled"/>
......@@ -6571,6 +6571,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram_suffixes>
<histogram_suffixes name="FirstDownload" separator=".">
<obsolete>
Removed 2020-10.
</obsolete>
<suffix name="FirstDownload" label="First download after startup."/>
<affected-histogram name="MobileDownload.Background"/>
</histogram_suffixes>
......
......@@ -619,6 +619,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<histogram name="MobileDownload.Background"
enum="MobileDownloadBackgroundDownloadEvent" expires_after="2020-10-11">
<obsolete>
Removed 2020-10.
</obsolete>
<owner>hnakashima@chromium.org</owner>
<owner>hanxi@chromium.org</owner>
<owner>yfriedman@chromium.org</owner>
......
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