Commit d17ee1b7 authored by fukino's avatar fukino Committed by Commit bot

Fix some type check errors in file_manager.

This CL includes following changes.
- Change openView_.firstNode to openView_.firstChild.
- Convert dynamically decorated metric functions to standard form to annotate them.
- Make MetadataCache.get's callback nullable.

BUG=406995
TEST=run browser_tests gtest_filter=*FileManager*

Review URL: https://codereview.chromium.org/673933003

Cr-Commit-Position: refs/heads/master@{#301341}
parent 16390930
...@@ -195,7 +195,7 @@ MetadataCache.prototype.currentEvictionThreshold_ = function() { ...@@ -195,7 +195,7 @@ MetadataCache.prototype.currentEvictionThreshold_ = function() {
* *
* @param {Array.<Entry>} entries The list of entries. * @param {Array.<Entry>} entries The list of entries.
* @param {string} type The metadata type. * @param {string} type The metadata type.
* @param {function(Object)} callback The metadata is passed to callback. * @param {?function(Object)} callback The metadata is passed to callback.
* The callback is called asynchronously. * The callback is called asynchronously.
*/ */
MetadataCache.prototype.get = function(entries, type, callback) { MetadataCache.prototype.get = function(entries, type, callback) {
...@@ -208,7 +208,7 @@ MetadataCache.prototype.get = function(entries, type, callback) { ...@@ -208,7 +208,7 @@ MetadataCache.prototype.get = function(entries, type, callback) {
* *
* @param {Array.<Entry>} entries The list of entries. * @param {Array.<Entry>} entries The list of entries.
* @param {string} type The metadata type. * @param {string} type The metadata type.
* @param {function(Object)} callback The metadata is passed to callback. * @param {?function(Object)} callback The metadata is passed to callback.
* The callback is called asynchronously. * The callback is called asynchronously.
*/ */
MetadataCache.prototype.getLatest = function(entries, type, callback) { MetadataCache.prototype.getLatest = function(entries, type, callback) {
...@@ -222,7 +222,7 @@ MetadataCache.prototype.getLatest = function(entries, type, callback) { ...@@ -222,7 +222,7 @@ MetadataCache.prototype.getLatest = function(entries, type, callback) {
* @param {string} type The metadata type. * @param {string} type The metadata type.
* @param {boolean} refresh True to get the latest value and refresh the cache, * @param {boolean} refresh True to get the latest value and refresh the cache,
* false to get the value from the cache. * false to get the value from the cache.
* @param {function(Object)} callback The metadata is passed to callback. * @param {?function(Object)} callback The metadata is passed to callback.
* The callback is called asynchronously. * The callback is called asynchronously.
* @private * @private
*/ */
......
...@@ -41,39 +41,54 @@ metrics.convertName_ = function(name) { ...@@ -41,39 +41,54 @@ metrics.convertName_ = function(name) {
/** /**
* Wrapper method for calling chrome.fileManagerPrivate safely. * Wrapper method for calling chrome.fileManagerPrivate safely.
* @param {string} name Method name. * @param {string} methodName Method name.
* @param {Array.<Object>} args Arguments. * @param {Array.<Object>} args Arguments.
* @private * @private
*/ */
metrics.call_ = function(name, args) { metrics.call_ = function(methodName, args) {
try { try {
chrome.metricsPrivate[name].apply(chrome.metricsPrivate, args); chrome.metricsPrivate[methodName].apply(chrome.metricsPrivate, args);
} catch (e) { } catch (e) {
console.error(e.stack); console.error(e.stack);
} }
if (metrics.log)
console.log('chrome.metricsPrivate.' + methodName, args);
}; };
/** /**
* Create a decorator function that calls a chrome.metricsPrivate function * Records a value than can range from 1 to 10,000.
* with the same name and correct parameters. * @param {string} name Short metric name.
* * @param {number} value Value to be recorded.
* @param {string} name Method name.
*/ */
metrics.decorate = function(name) { metrics.recordMediumCount = function(name, value) {
metrics[name] = function() { metrics.call_('recordMediumCount', [metrics.convertName_(name), value]);
var args = Array.apply(null, arguments); };
args[0] = metrics.convertName_(args[0]);
metrics.call_(name, args); /**
if (metrics.log) { * Records a value than can range from 1 to 100.
console.log('chrome.metricsPrivate.' + name, args); * @param {string} name Short metric name.
} * @param {number} value Value to be recorded.
}; */
metrics.recordSmallCount = function(name, value) {
metrics.call_('recordSmallCount', [metrics.convertName_(name), value]);
};
/**
* Records an elapsed time of no more than 10 seconds.
* @param {string} name Short metric name.
* @param {number} time Time to be recorded in milliseconds.
*/
metrics.recordTime = function(name, time) {
metrics.call_('recordTime', [metrics.convertName_(name), time]);
}; };
metrics.decorate('recordMediumCount'); /**
metrics.decorate('recordSmallCount'); * Records an action performed by the user.
metrics.decorate('recordTime'); * @param {string} name Short metric name.
metrics.decorate('recordUserAction'); */
metrics.recordUserAction = function(name) {
metrics.call_('recordUserAction', [metrics.convertName_(name)]);
};
/** /**
* Complete the time interval recording. * Complete the time interval recording.
...@@ -124,8 +139,4 @@ metrics.recordEnum = function(name, value, validValues) { ...@@ -124,8 +139,4 @@ metrics.recordEnum = function(name, value, validValues) {
'buckets': boundaryValue + 1 'buckets': boundaryValue + 1
}; };
metrics.call_('recordValue', [metricDescr, index]); metrics.call_('recordValue', [metricDescr, index]);
if (metrics.log) {
console.log('chrome.metricsPrivate.recordValue',
[metricDescr.metricName, index, value]);
}
}; };
...@@ -179,10 +179,12 @@ function ProgressCenterPanel(element) { ...@@ -179,10 +179,12 @@ function ProgressCenterPanel(element) {
/** /**
* Open view containing multiple progress items. * Open view containing multiple progress items.
* @type {Element} * @type {!HTMLDivElement}
* @private * @private
*/ */
this.openView_ = this.element_.querySelector('#progress-center-open-view'); this.openView_ = assertInstanceof(
queryRequiredElement(this.element_, '#progress-center-open-view'),
HTMLDivElement);
/** /**
* Close view that is a summarized progress item. * Close view that is a summarized progress item.
......
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