Chromium Code Reviews| Index: ui/file_manager/file_manager/background/js/import_history.js |
| diff --git a/ui/file_manager/file_manager/background/js/import_history.js b/ui/file_manager/file_manager/background/js/import_history.js |
| index 397ecb93c8a98d7e3b631f35b75e6738a1d2ae2b..e69ce262ae4ecd9e01e448bba914642a6b42e841 100644 |
| --- a/ui/file_manager/file_manager/background/js/import_history.js |
| +++ b/ui/file_manager/file_manager/background/js/import_history.js |
| @@ -613,8 +613,9 @@ importer.HistoryLoader.prototype.addHistoryLoadedListener; |
| * @struct |
| * |
| * @param {function(): !Promise<!Array<!FileEntry>>} filesProvider |
| + * @param {!analytics.Tracker} tracker |
| */ |
| -importer.SynchronizedHistoryLoader = function(filesProvider) { |
| +importer.SynchronizedHistoryLoader = function(filesProvider, tracker) { |
| /** |
| * @return {!Promise<!Array<!FileEntry>>} History files. Will always |
| * have at least one file (the "primary file"). When other devices |
| @@ -625,6 +626,9 @@ importer.SynchronizedHistoryLoader = function(filesProvider) { |
| */ |
| this.getHistoryFiles_ = filesProvider; |
| + /** @private {!analytics.Tracker} */ |
| + this.tracker_ = tracker; |
| + |
| /** @private {boolean} */ |
| this.needsInitialization_ = true; |
| @@ -644,7 +648,9 @@ importer.SynchronizedHistoryLoader.prototype.getHistory = function() { |
| * @this {importer.SynchronizedHistoryLoader} |
| */ |
| function(fileEntries) { |
| - var storage = new importer.FileBasedRecordStorage(fileEntries); |
| + var storage = new importer.FileBasedRecordStorage( |
| + fileEntries, |
| + this.tracker_); |
| var history = new importer.PersistentImportHistory( |
| importer.createMetadataHashcode, |
| storage); |
| @@ -700,8 +706,10 @@ importer.RecordStorage.prototype.readAll; |
| * @constructor |
| * @implements {importer.RecordStorage} |
| * @struct |
| + * |
| + * @param {!analytics.Tracker} tracker |
| */ |
| -importer.FileBasedRecordStorage = function(fileEntries) { |
| +importer.FileBasedRecordStorage = function(fileEntries, tracker) { |
| /** @private {!Array<!importer.PromisingFileEntry>} */ |
| this.inputFiles_ = fileEntries.map( |
| importer.PromisingFileEntry.create); |
| @@ -709,6 +717,9 @@ importer.FileBasedRecordStorage = function(fileEntries) { |
| /** @private {!importer.PromisingFileEntry} */ |
| this.outputFile_ = this.inputFiles_[0]; |
| + /** @private {!analytics.Tracker} */ |
| + this.tracker_ = tracker; |
| + |
| /** |
| * Serializes all writes and reads on the primary file. |
| * @private {!Promise<?>} |
| @@ -762,13 +773,17 @@ importer.FileBasedRecordStorage.prototype.writeRecord_ = |
| /** @override */ |
| importer.FileBasedRecordStorage.prototype.readAll = function(recordCallback) { |
| + var processTiming = this.tracker_.startTiming( |
| + metrics.Categories.ACQUISITION, |
| + metrics.timing.Variables.HISTORY_LOAD); |
| + |
| return this.latestOperation_ = this.latestOperation_ |
| .then( |
| /** |
| - * @param {?} ignore |
| + * @param {?} ignored |
|
Ben Kwa
2015/03/18 21:37:15
Is this here to stop the compiler from complaining
Steve McKay
2015/03/18 22:47:51
Honestly, I don't know. I just typed it according
|
| * @this {importer.FileBasedRecordStorage} |
| */ |
| - function(ignore) { |
| + function(ignored) { |
| var filePromises = this.inputFiles_.map( |
| /** |
| * @param {!importer.PromisingFileEntry} entry |
| @@ -815,6 +830,16 @@ importer.FileBasedRecordStorage.prototype.readAll = function(recordCallback) { |
| function(recordSet) { |
| recordSet.forEach(recordCallback); |
| }); |
| + |
| + processTiming.send(); |
| + |
| + var fileCount = this.inputFiles_.length; |
| + this.tracker_.send( |
| + metrics.ImportEvents.HISTORY_LOADED |
| + .value(fileCount) |
| + .dimension(fileCount === 1 |
| + ? metrics.Dimensions.MACHINE_USE_SINGLE |
| + : metrics.Dimensions.MACHINE_USE_MULTIPLE)); |
| }.bind(this)) |
| .catch(importer.getLogger().catcher('file-record-store-read-all')); |
| }; |
| @@ -1047,8 +1072,18 @@ importer.DriveSyncWatcher.prototype.getSyncStatus_ = |
| * @constructor |
| * @implements {importer.HistoryLoader} |
| * @struct |
| + * |
| + * @param {!analytics.Tracker} tracker |
| */ |
| -importer.RuntimeHistoryLoader = function() { |
| +importer.RuntimeHistoryLoader = function(tracker) { |
| + |
| + /** @return {!importer.HistoryLoader} */ |
| + this.createRealHistoryLoader_ = function() { |
|
Ben Kwa
2015/03/18 21:37:15
Why'd you do this instead of making this a proper
Steve McKay
2015/03/18 22:47:51
No, I did this to avoid saving off tracker in a fi
|
| + return new importer.SynchronizedHistoryLoader( |
| + importer.getHistoryFiles, |
| + tracker); |
| + }; |
| + |
| /** @private {boolean} */ |
| this.needsInitialization_ = true; |
| @@ -1065,13 +1100,13 @@ importer.RuntimeHistoryLoader.prototype.getHistory = function() { |
| /** |
| * @param {boolean} enabled |
| * @return {!importer.HistoryLoader} |
| + * @this {importer.RuntimeHistoryLoader} |
| */ |
| function(enabled) { |
| return enabled ? |
| - new importer.SynchronizedHistoryLoader( |
| - importer.getHistoryFiles) : |
| + this.createRealHistoryLoader_() : |
| new importer.DummyImportHistory(false); |
| - }) |
| + }.bind(this)) |
| .then( |
| /** |
| * @param {!importer.HistoryLoader} loader |