Commit b35d45fc authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: ES6 class metadata_box_controller.js and quick_view_uma.js

Bug: 778674
Change-Id: I4f60e40748696de54ed1925aa397cfdcb218edce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760584
Commit-Queue: Noel Gordon <noel@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688472}
parent 9eda4e5a
...@@ -4,23 +4,83 @@ ...@@ -4,23 +4,83 @@
/** /**
* UMA exporter for Quick View. * UMA exporter for Quick View.
*
* @param {!VolumeManager} volumeManager
* @param {!DialogType} dialogType
*
* @constructor
*/ */
function QuickViewUma(volumeManager, dialogType) { class QuickViewUma {
/** /**
* @type {!VolumeManager} * @param {!VolumeManager} volumeManager
* @private * @param {!DialogType} dialogType
*/ */
this.volumeManager_ = volumeManager; constructor(volumeManager, dialogType) {
/**
* @type {!VolumeManager}
* @private
*/
this.volumeManager_ = volumeManager;
/**
* @type {DialogType}
* @private
*/
this.dialogType_ = dialogType;
}
/** /**
* @type {DialogType} * Exports file type metric with the given |name|.
*
* @param {!FileEntry} entry
* @param {string} name The histogram name.
*
* @private * @private
*/ */
this.dialogType_ = dialogType; exportFileType_(entry, name) {
let extension = FileType.getExtension(entry).toLowerCase();
if (entry.isDirectory) {
extension = 'directory';
} else if (extension === '') {
extension = 'no extension';
} else if (FileTasks.UMA_INDEX_KNOWN_EXTENSIONS.indexOf(extension) < 0) {
extension = 'unknown extension';
}
metrics.recordEnum(name, extension, FileTasks.UMA_INDEX_KNOWN_EXTENSIONS);
}
/**
* Exports UMA based on the entry shown in Quick View.
*
* @param {!FileEntry} entry
*/
onEntryChanged(entry) {
this.exportFileType_(entry, 'QuickView.FileType');
}
/**
* Exports UMA based on the entry selected when Quick View is opened.
*
* @param {!FileEntry} entry
* @param {QuickViewUma.WayToOpen} wayToOpen
*/
onOpened(entry, wayToOpen) {
this.exportFileType_(entry, 'QuickView.FileTypeOnLaunch');
metrics.recordEnum(
'QuickView.WayToOpen', wayToOpen, QuickViewUma.WayToOpenValues_);
const volumeType = this.volumeManager_.getVolumeInfo(entry).volumeType;
if (QuickViewUma.VolumeType.includes(volumeType)) {
metrics.recordEnum(
'QuickView.VolumeType', volumeType, QuickViewUma.VolumeType);
} else {
console.error('Unknown volume type: ' + volumeType);
}
// Record stats of dialog types. It must be in sync with
// FileDialogType enum in tools/metrics/histograms/histogram.xml.
metrics.recordEnum('QuickView.DialogType', this.dialogType_, [
DialogType.SELECT_FOLDER,
DialogType.SELECT_UPLOAD_FOLDER,
DialogType.SELECT_SAVEAS_FILE,
DialogType.SELECT_OPEN_FILE,
DialogType.SELECT_OPEN_MULTI_FILE,
DialogType.FULL_PAGE,
]);
}
} }
/** /**
...@@ -65,62 +125,3 @@ QuickViewUma.VolumeType = [ ...@@ -65,62 +125,3 @@ QuickViewUma.VolumeType = [
VolumeManagerCommon.VolumeType.ANDROID_FILES, VolumeManagerCommon.VolumeType.ANDROID_FILES,
VolumeManagerCommon.VolumeType.DOCUMENTS_PROVIDER, VolumeManagerCommon.VolumeType.DOCUMENTS_PROVIDER,
]; ];
/**
* Exports file type metric with the given |name|.
*
* @param {!FileEntry} entry
* @param {string} name The histogram name.
*
* @private
*/
QuickViewUma.prototype.exportFileType_ = (entry, name) => {
let extension = FileType.getExtension(entry).toLowerCase();
if (entry.isDirectory) {
extension = 'directory';
} else if (extension === '') {
extension = 'no extension';
} else if (FileTasks.UMA_INDEX_KNOWN_EXTENSIONS.indexOf(extension) < 0) {
extension = 'unknown extension';
}
metrics.recordEnum(name, extension, FileTasks.UMA_INDEX_KNOWN_EXTENSIONS);
};
/**
* Exports UMA based on the entry shown in Quick View.
*
* @param {!FileEntry} entry
*/
QuickViewUma.prototype.onEntryChanged = function(entry) {
this.exportFileType_(entry, 'QuickView.FileType');
};
/**
* Exports UMA based on the entry selected when Quick View is opened.
*
* @param {!FileEntry} entry
* @param {QuickViewUma.WayToOpen} wayToOpen
*/
QuickViewUma.prototype.onOpened = function(entry, wayToOpen) {
this.exportFileType_(entry, 'QuickView.FileTypeOnLaunch');
metrics.recordEnum(
'QuickView.WayToOpen', wayToOpen, QuickViewUma.WayToOpenValues_);
const volumeType = this.volumeManager_.getVolumeInfo(entry).volumeType;
if (QuickViewUma.VolumeType.includes(volumeType)) {
metrics.recordEnum(
'QuickView.VolumeType', volumeType, QuickViewUma.VolumeType);
} else {
console.error('Unknown volume type: ' + volumeType);
}
// Record stats of dialog types. It must be in sync with
// FileDialogType enum in tools/metrics/histograms/histogram.xml.
metrics.recordEnum('QuickView.DialogType', this.dialogType_, [
DialogType.SELECT_FOLDER,
DialogType.SELECT_UPLOAD_FOLDER,
DialogType.SELECT_SAVEAS_FILE,
DialogType.SELECT_OPEN_FILE,
DialogType.SELECT_OPEN_MULTI_FILE,
DialogType.FULL_PAGE,
]);
};
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