Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: ui/file_manager/file_manager/foreground/js/import_controller.js

Issue 1045663002: Cancel scans when directory changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to review comments. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Namespace 5 // Namespace
6 var importer = importer || {}; 6 var importer = importer || {};
7 7
8 /** @private @enum {string} */ 8 /** @private @enum {string} */
9 importer.ActivityState = { 9 importer.ActivityState = {
10 READY: 'ready', 10 READY: 'ready',
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 var listener = this.onScanEvent_.bind(this); 74 var listener = this.onScanEvent_.bind(this);
75 this.scanner_.addObserver(listener); 75 this.scanner_.addObserver(listener);
76 // Remove the observer when the foreground window is closed. 76 // Remove the observer when the foreground window is closed.
77 window.addEventListener( 77 window.addEventListener(
78 'pagehide', 78 'pagehide',
79 function() { 79 function() {
80 this.scanner_.removeObserver(listener); 80 this.scanner_.removeObserver(listener);
81 }.bind(this)); 81 }.bind(this));
82 82
83 this.environment_.addWindowCloseListener(
84 this.onWindowClosing_.bind(this));
85
83 this.environment_.addVolumeUnmountListener( 86 this.environment_.addVolumeUnmountListener(
84 this.onVolumeUnmounted_.bind(this)); 87 this.onVolumeUnmounted_.bind(this));
85 88
86 this.environment_.addDirectoryChangedListener( 89 this.environment_.addDirectoryChangedListener(
87 this.onDirectoryChanged_.bind(this)); 90 this.onDirectoryChanged_.bind(this));
88 91
89 this.environment_.addSelectionChangedListener( 92 this.environment_.addSelectionChangedListener(
90 this.onSelectionChanged_.bind(this)); 93 this.onSelectionChanged_.bind(this));
91 94
92 this.commandWidget_.addClickListener( 95 this.commandWidget_.addClickListener(
(...skipping 28 matching lines...) Expand all
121 * 124 *
122 * @private 125 * @private
123 */ 126 */
124 importer.ImportController.prototype.onScanEvent_ = function(event, scan) { 127 importer.ImportController.prototype.onScanEvent_ = function(event, scan) {
125 if (!this.scanManager_.isActiveScan(scan)) { 128 if (!this.scanManager_.isActiveScan(scan)) {
126 return; 129 return;
127 } 130 }
128 131
129 switch (event) { 132 switch (event) {
130 case importer.ScanEvent.INVALIDATED: 133 case importer.ScanEvent.INVALIDATED:
131 this.scanManager_.reset(); 134 this.onScanInvalidated_();
132 case importer.ScanEvent.FINALIZED: 135 case importer.ScanEvent.FINALIZED:
133 case importer.ScanEvent.UPDATED: 136 case importer.ScanEvent.UPDATED:
134 this.checkState_(scan); 137 this.checkState_(scan);
135 break; 138 break;
136 } 139 }
137 }; 140 };
138 141
142 /** @private */
143 importer.ImportController.prototype.onWindowClosing_ = function() {
144 this.scanManager_.reset(); // Will cancel any active scans.
145 };
146
139 /** 147 /**
140 * @param {string} volumeId 148 * @param {string} volumeId
141 * @private 149 * @private
142 */ 150 */
143 importer.ImportController.prototype.onVolumeUnmounted_ = function(volumeId) { 151 importer.ImportController.prototype.onVolumeUnmounted_ = function(volumeId) {
144 if (this.activeImport_) { 152 if (this.activeImport_) {
145 this.activeImport_.task.requestCancel(); 153 this.activeImport_.task.requestCancel();
146 this.finalizeActiveImport_(); 154 this.finalizeActiveImport_();
147 this.tracker_.send(metrics.ImportEvents.DEVICE_YANKED); 155 this.tracker_.send(metrics.ImportEvents.DEVICE_YANKED);
148 } 156 }
149 this.scanManager_.reset(); 157 this.scanManager_.reset();
150 this.checkState_(); 158 this.checkState_();
151 }; 159 };
152 160
153 /** 161 /**
154 * @param {!Event} event 162 * @param {!Event} event
155 * @private 163 * @private
156 */ 164 */
157 importer.ImportController.prototype.onDirectoryChanged_ = function(event) { 165 importer.ImportController.prototype.onDirectoryChanged_ = function(event) {
158 if (!event.previousDirEntry && 166 if (!event.previousDirEntry &&
159 event.newDirEntry && 167 event.newDirEntry &&
160 importer.isMediaDirectory(event.newDirEntry, this.environment_)) { 168 importer.isMediaDirectory(event.newDirEntry, this.environment_)) {
161 this.commandWidget_.setDetailsVisible(true); 169 this.commandWidget_.setDetailsVisible(true);
162 } 170 }
163 this.scanManager_.clearSelectionScan(); 171
172 this.scanManager_.reset();
164 if (this.isCurrentDirectoryScannable_()) { 173 if (this.isCurrentDirectoryScannable_()) {
165 this.checkState_( 174 this.checkState_(
166 this.scanManager_.getCurrentDirectoryScan()); 175 this.scanManager_.getDirectoryScan());
167 } else { 176 } else {
168 this.checkState_(); 177 this.checkState_();
169 } 178 }
170 }; 179 };
171 180
172 /** @private */ 181 /** @private */
173 importer.ImportController.prototype.onSelectionChanged_ = function() { 182 importer.ImportController.prototype.onSelectionChanged_ = function() {
183 // NOTE: Empty selection changed events can and will fire for a directory
184 // before we receive the the corresponding directory changed event
185 // and when the selection is empty. These are spurios events
186 // and we ignore them.
187 if (!this.scanManager_.hasSelectionScan() &&
188 this.environment_.getSelection().length === 0) {
189 return;
190 }
191
174 // NOTE: We clear the scan here, but don't immediately initiate 192 // NOTE: We clear the scan here, but don't immediately initiate
175 // a new scan. checkState will attempt to initialize the scan 193 // a new scan. checkState will attempt to initialize the scan
176 // during normal processing. 194 // during normal processing.
177 // Also, in the case the selection is transitioning to empty, 195 // Also, in the case the selection is transitioning to empty,
178 // we want to reinstate the underlying directory scan (if 196 // we want to reinstate the underlying directory scan (if
179 // in fact, one is possible). 197 // in fact, one is possible).
180 this.scanManager_.clearSelectionScan(); 198 this.scanManager_.clearSelectionScan();
181 if (this.environment_.getSelection().length === 0 && 199 if (this.environment_.getSelection().length === 0 &&
182 this.isCurrentDirectoryScannable_()) { 200 this.isCurrentDirectoryScannable_()) {
183 this.checkState_( 201 this.checkState_(
184 this.scanManager_.getCurrentDirectoryScan()); 202 this.scanManager_.getDirectoryScan());
185 } else { 203 } else {
186 this.checkState_(); 204 this.checkState_();
187 } 205 }
188 }; 206 };
189 207
190 /** 208 /**
191 * @param {!importer.MediaImportHandler.ImportTask} task 209 * @param {!importer.MediaImportHandler.ImportTask} task
192 * @private 210 * @private
193 */ 211 */
194 importer.ImportController.prototype.onImportFinished_ = function(task) { 212 importer.ImportController.prototype.onImportFinished_ = function(task) {
195 this.finalizeActiveImport_(); 213 this.finalizeActiveImport_();
196 this.scanManager_.reset(); 214 this.scanManager_.reset();
197 this.storage_.set(importer.Setting.HAS_COMPLETED_IMPORT, true); 215 this.storage_.set(importer.Setting.HAS_COMPLETED_IMPORT, true);
198 this.commandWidget_.setDetailsBannerVisible(false); 216 this.commandWidget_.setDetailsBannerVisible(false);
199 this.checkState_(); 217 this.checkState_();
200 }; 218 };
201 219
220 /** @private */
221 importer.ImportController.prototype.onScanInvalidated_ = function() {
222 this.scanManager_.reset();
223 if (this.environment_.getSelection().length === 0 &&
224 this.isCurrentDirectoryScannable_()) {
225 this.checkState_(
226 this.scanManager_.getDirectoryScan());
227 } else {
228 this.checkState_();
229 }
230 };
231
202 /** 232 /**
203 * Does book keeping necessary to finalize the active task. 233 * Does book keeping necessary to finalize the active task.
204 * @private 234 * @private
205 */ 235 */
206 importer.ImportController.prototype.finalizeActiveImport_ = function() { 236 importer.ImportController.prototype.finalizeActiveImport_ = function() {
207 console.assert(!!this.activeImport_, 237 console.assert(!!this.activeImport_,
208 'Cannot finish import when none is running.'); 238 'Cannot finish import when none is running.');
209 this.previousImport_ = this.activeImport_; 239 this.previousImport_ = this.activeImport_;
210 this.activeImport_ = null; 240 this.activeImport_ = null;
211 }; 241 };
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 var taskFinished = this.onImportFinished_.bind(this, importTask); 305 var taskFinished = this.onImportFinished_.bind(this, importTask);
276 importTask.whenFinished.then(taskFinished).catch(taskFinished); 306 importTask.whenFinished.then(taskFinished).catch(taskFinished);
277 this.checkState_(); 307 this.checkState_();
278 }; 308 };
279 309
280 /** 310 /**
281 * Cancels the active task. 311 * Cancels the active task.
282 * @private 312 * @private
283 */ 313 */
284 importer.ImportController.prototype.cancel_ = function() { 314 importer.ImportController.prototype.cancel_ = function() {
285 this.activeImport_.task.requestCancel(); 315 if (this.activeImport_) {
286 this.finalizeActiveImport_(); 316 this.activeImport_.task.requestCancel();
287 this.tracker_.send(metrics.ImportEvents.IMPORT_CANCELLED); 317 this.finalizeActiveImport_();
318 this.tracker_.send(metrics.ImportEvents.IMPORT_CANCELLED);
319 }
288 320
289 this.scanManager_.reset(); 321 this.scanManager_.reset();
290 this.checkState_(); 322 this.checkState_();
291 }; 323 };
292 324
293 /** 325 /**
294 * Checks the environment and updates UI as needed. 326 * Checks the environment and updates UI as needed.
295 * @param {importer.ScanResult=} opt_scan If supplied, 327 * @param {importer.ScanResult=} opt_scan If supplied,
296 * @private 328 * @private
297 */ 329 */
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 436
405 /** 437 /**
406 * Attempts to scan the current context. 438 * Attempts to scan the current context.
407 * 439 *
408 * @return {importer.ScanResult} A scan object, 440 * @return {importer.ScanResult} A scan object,
409 * or null if scan is not possible in current context. 441 * or null if scan is not possible in current context.
410 * @private 442 * @private
411 */ 443 */
412 importer.ImportController.prototype.tryScan_ = function() { 444 importer.ImportController.prototype.tryScan_ = function() {
413 var entries = this.environment_.getSelection(); 445 var entries = this.environment_.getSelection();
414
415 if (entries.length) { 446 if (entries.length) {
416 if (entries.every( 447 if (entries.every(
417 importer.isEligibleEntry.bind(null, this.environment_))) { 448 importer.isEligibleEntry.bind(null, this.environment_))) {
418 return this.scanManager_.getSelectionScan(entries); 449 return this.scanManager_.getSelectionScan(entries);
419 } 450 }
420 } else if (this.isCurrentDirectoryScannable_()) { 451 } else if (this.isCurrentDirectoryScannable_()) {
421 return this.scanManager_.getCurrentDirectoryScan(); 452 return this.scanManager_.getDirectoryScan();
422 } 453 }
423 454
424 return null; 455 return null;
425 }; 456 };
426 457
427 /** 458 /**
428 * Class that adapts from the new non-command button to the old 459 * Class that adapts from the new non-command button to the old
429 * command style interface. 460 * command style interface.
430 * 461 *
431 * @interface 462 * @interface
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 */ 826 */
796 importer.ScanManager = function(environment, scanner) { 827 importer.ScanManager = function(environment, scanner) {
797 828
798 /** @private {!importer.ControllerEnvironment} */ 829 /** @private {!importer.ControllerEnvironment} */
799 this.environment_ = environment; 830 this.environment_ = environment;
800 831
801 /** @private {!importer.MediaScanner} */ 832 /** @private {!importer.MediaScanner} */
802 this.scanner_ = scanner; 833 this.scanner_ = scanner;
803 834
804 /** 835 /**
805 * A cache of selection scans by directory (url). 836 * The active files scan, if any.
806 * 837 *
807 * @private {importer.ScanResult} 838 * @private {importer.ScanResult}
808 */ 839 */
809 this.selectionScan_ = null; 840 this.selectionScan_ = null;
810 841
811 /** 842 /**
812 * A cache of scans by directory (url). 843 * The active directory scan, if any.
813 * 844 *
814 * @private {!Object.<string, !importer.ScanResult>} 845 * @private {importer.ScanResult}
815 */ 846 */
816 this.directoryScans_ = {}; 847 this.directoryScan_ = null;
817 }; 848 };
818 849
819 /** 850 /**
820 * Forgets all scans. 851 * Cancels and forgets all scans.
821 */ 852 */
822 importer.ScanManager.prototype.reset = function() { 853 importer.ScanManager.prototype.reset = function() {
823 this.clearSelectionScan(); 854 this.clearSelectionScan();
824 this.clearDirectoryScans(); 855 this.clearDirectoryScan();
825 }; 856 };
826 857
827 /** 858 /**
828 * Forgets the selection scans for the current directory. 859 * @return {boolean} True if we have an existing selection scan.
860 */
861 importer.ScanManager.prototype.hasSelectionScan = function() {
862 return !!this.selectionScan_;
863 };
864
865 /**
866 * Cancels and forgets the current selection scan, if any.
829 */ 867 */
830 importer.ScanManager.prototype.clearSelectionScan = function() { 868 importer.ScanManager.prototype.clearSelectionScan = function() {
869 if (this.selectionScan_) {
870 this.selectionScan_.cancel();
871 }
831 this.selectionScan_ = null; 872 this.selectionScan_ = null;
832 }; 873 };
833 874
834 /** 875 /**
835 * Forgets directory scans. 876 * Cancels and forgets the current directory scan, if any.
836 */ 877 */
837 importer.ScanManager.prototype.clearDirectoryScans = function() { 878 importer.ScanManager.prototype.clearDirectoryScan = function() {
838 this.directoryScans_ = {}; 879 if (this.directoryScan_) {
880 this.directoryScan_.cancel();
881 }
882 this.directoryScan_ = null;
839 }; 883 };
840 884
841 /** 885 /**
842 * @return {importer.ScanResult} Current active scan, or null 886 * @return {importer.ScanResult} Current active scan, or null
843 * if none. 887 * if none.
844 */ 888 */
845 importer.ScanManager.prototype.getActiveScan = function() { 889 importer.ScanManager.prototype.getActiveScan = function() {
846 if (!!this.selectionScan_) { 890 return this.selectionScan_ || this.directoryScan_;
847 return this.selectionScan_;
848 }
849 var directory = this.environment_.getCurrentDirectory();
850 if (directory) {
851 return this.directoryScans_[directory.toURL()];
852 }
853 return null;
854 }; 891 };
855 892
856 /** 893 /**
857 * @param {importer.ScanResult} scan 894 * @param {importer.ScanResult} scan
858 * @return {boolean} True if scan is the active scan...meaning the current 895 * @return {boolean} True if scan is the active scan...meaning the current
859 * selection scan or the scan for the current directory. 896 * selection scan or the scan for the current directory.
860 */ 897 */
861 importer.ScanManager.prototype.isActiveScan = function(scan) { 898 importer.ScanManager.prototype.isActiveScan = function(scan) {
862 if (scan === this.selectionScan_) { 899 return scan === this.selectionScan_ || scan === this.directoryScan_;
863 return true;
864 }
865
866 var directory = this.environment_.getCurrentDirectory();
867 return !!directory &&
868 scan === this.directoryScans_[directory.toURL()];
869 }; 900 };
870 901
871 /** 902 /**
872 * Returns the existing selection scan or a new one for the supplied 903 * Returns the existing selection scan or a new one for the supplied
873 * selection. 904 * selection.
874 * 905 *
875 * @param {!Array.<!FileEntry>} entries 906 * @param {!Array.<!FileEntry>} entries
876 * 907 *
877 * @return {!importer.ScanResult} 908 * @return {!importer.ScanResult}
878 */ 909 */
879 importer.ScanManager.prototype.getSelectionScan = function(entries) { 910 importer.ScanManager.prototype.getSelectionScan = function(entries) {
880 console.assert(!this.selectionScan_, 911 console.assert(!this.selectionScan_,
881 'Cannot create new selection scan with another in the cache.'); 912 'Cannot create new selection scan with another in the cache.');
882 this.selectionScan_ = this.scanner_.scanFiles(entries); 913 this.selectionScan_ = this.scanner_.scanFiles(entries);
883 return this.selectionScan_; 914 return this.selectionScan_;
884 }; 915 };
885 916
886 /** 917 /**
887 * Returns a scan for the directory. 918 * Returns a scan for the directory.
888 * 919 *
889 * @return {importer.ScanResult} 920 * @return {importer.ScanResult}
890 */ 921 */
891 importer.ScanManager.prototype.getCurrentDirectoryScan = function() { 922 importer.ScanManager.prototype.getDirectoryScan = function() {
892 var directory = this.environment_.getCurrentDirectory(); 923 if (!this.directoryScan_) {
893 if (!directory) { 924 var directory = this.environment_.getCurrentDirectory();
894 return null; 925 if (directory) {
926 this.directoryScan_ = this.scanner_.scanDirectory(
927 /** @type {!DirectoryEntry} */ (directory));
928 }
895 } 929 }
896 930 return this.directoryScan_;
897 var url = directory.toURL();
898 var scan = this.directoryScans_[url];
899 if (!scan) {
900 scan = this.scanner_.scanDirectory(
901 /** @type {!DirectoryEntry} */ (directory));
902 this.directoryScans_[url] = scan;
903 }
904
905 return scan;
906 }; 931 };
907 932
908 /** 933 /**
909 * Interface abstracting away the concrete file manager available 934 * Interface abstracting away the concrete file manager available
910 * to commands. By hiding file manager we make it easy to test 935 * to commands. By hiding file manager we make it easy to test
911 * ImportController. 936 * ImportController.
912 * 937 *
913 * @interface 938 * @interface
914 * @extends {VolumeManagerCommon.VolumeInfoProvider} 939 * @extends {VolumeManagerCommon.VolumeInfoProvider}
915 */ 940 */
(...skipping 22 matching lines...) Expand all
938 */ 963 */
939 importer.ControllerEnvironment.prototype.isGoogleDriveMounted; 964 importer.ControllerEnvironment.prototype.isGoogleDriveMounted;
940 965
941 /** 966 /**
942 * Returns the available space for the local volume in bytes. 967 * Returns the available space for the local volume in bytes.
943 * @return {!Promise<number>} 968 * @return {!Promise<number>}
944 */ 969 */
945 importer.ControllerEnvironment.prototype.getFreeStorageSpace; 970 importer.ControllerEnvironment.prototype.getFreeStorageSpace;
946 971
947 /** 972 /**
973 * Installs a 'window closed' listener. Listener is called just
974 * just before the window is closed. Any business must be
975 * done synchronously.
976 * @param {function()} listener
977 */
978 importer.ControllerEnvironment.prototype.addWindowCloseListener;
979
980 /**
948 * Installs an 'unmount' listener. Listener is called with 981 * Installs an 'unmount' listener. Listener is called with
949 * the corresponding volume id when a volume is unmounted. 982 * the corresponding volume id when a volume is unmounted.
950 * @param {function(string)} listener 983 * @param {function(string)} listener
951 */ 984 */
952 importer.ControllerEnvironment.prototype.addVolumeUnmountListener; 985 importer.ControllerEnvironment.prototype.addVolumeUnmountListener;
953 986
954 /** 987 /**
955 * Installs an 'directory-changed' listener. Listener is called when 988 * Installs an 'directory-changed' listener. Listener is called when
956 * the directory changed. 989 * the directory changed.
957 * @param {function(!Event)} listener 990 * @param {function(!Event)} listener
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1075
1043 /** @override */ 1076 /** @override */
1044 importer.RuntimeControllerEnvironment.prototype.isGoogleDriveMounted = 1077 importer.RuntimeControllerEnvironment.prototype.isGoogleDriveMounted =
1045 function() { 1078 function() {
1046 var drive = this.fileManager_.volumeManager.getCurrentProfileVolumeInfo( 1079 var drive = this.fileManager_.volumeManager.getCurrentProfileVolumeInfo(
1047 VolumeManagerCommon.VolumeType.DRIVE); 1080 VolumeManagerCommon.VolumeType.DRIVE);
1048 return !!drive; 1081 return !!drive;
1049 }; 1082 };
1050 1083
1051 /** @override */ 1084 /** @override */
1052 importer.RuntimeControllerEnvironment.prototype.addVolumeUnmountListener =
1053 function(listener) {
1054 // TODO(smckay): remove listeners when the page is torn down.
1055 chrome.fileManagerPrivate.onMountCompleted.addListener(
1056 /**
1057 * @param {!MountCompletedEvent} event
1058 * @this {importer.RuntimeControllerEnvironment}
1059 */
1060 function(event) {
1061 if (event.eventType === 'unmount') {
1062 listener(event.volumeMetadata.volumeId);
1063 }
1064 });
1065 };
1066
1067 /** @override */
1068 importer.RuntimeControllerEnvironment.prototype.getFreeStorageSpace = 1085 importer.RuntimeControllerEnvironment.prototype.getFreeStorageSpace =
1069 function() { 1086 function() {
1070 // Checking DOWNLOADS returns the amount of available local storage space. 1087 // Checking DOWNLOADS returns the amount of available local storage space.
1071 var localVolumeInfo = 1088 var localVolumeInfo =
1072 this.fileManager_.volumeManager.getCurrentProfileVolumeInfo( 1089 this.fileManager_.volumeManager.getCurrentProfileVolumeInfo(
1073 VolumeManagerCommon.VolumeType.DOWNLOADS); 1090 VolumeManagerCommon.VolumeType.DOWNLOADS);
1074 return new Promise( 1091 return new Promise(
1075 function(resolve, reject) { 1092 function(resolve, reject) {
1076 chrome.fileManagerPrivate.getSizeStats( 1093 chrome.fileManagerPrivate.getSizeStats(
1077 localVolumeInfo.volumeId, 1094 localVolumeInfo.volumeId,
1078 /** @param {Object} stats */ 1095 /** @param {Object} stats */
1079 function(stats) { 1096 function(stats) {
1080 if (stats && !chrome.runtime.lastError) { 1097 if (stats && !chrome.runtime.lastError) {
1081 resolve(stats.remainingSize); 1098 resolve(stats.remainingSize);
1082 } else { 1099 } else {
1083 reject('Failed to ascertain available free space: ' + 1100 reject('Failed to ascertain available free space: ' +
1084 chrome.runtime.lastError.message || 1101 chrome.runtime.lastError.message ||
1085 chrome.runtime.lastError); 1102 chrome.runtime.lastError);
1086 } 1103 }
1087 }); 1104 });
1088 }); 1105 });
1089 }; 1106 };
1090 1107
1091 /** @override */ 1108 /** @override */
1109 importer.RuntimeControllerEnvironment.prototype.addWindowCloseListener =
1110 function(listener) {
1111 window.addEventListener('pagehide', listener);
1112 };
1113
1114 /** @override */
1115 importer.RuntimeControllerEnvironment.prototype.addVolumeUnmountListener =
1116 function(listener) {
1117 // TODO(smckay): remove listeners when the page is torn down.
1118 chrome.fileManagerPrivate.onMountCompleted.addListener(
1119 /**
1120 * @param {!MountCompletedEvent} event
1121 * @this {importer.RuntimeControllerEnvironment}
1122 */
1123 function(event) {
1124 if (event.eventType === 'unmount') {
1125 listener(event.volumeMetadata.volumeId);
1126 }
1127 });
1128 };
1129
1130 /** @override */
1092 importer.RuntimeControllerEnvironment.prototype.addDirectoryChangedListener = 1131 importer.RuntimeControllerEnvironment.prototype.addDirectoryChangedListener =
1093 function(listener) { 1132 function(listener) {
1094 // TODO(smckay): remove listeners when the page is torn down. 1133 // TODO(smckay): remove listeners when the page is torn down.
1095 this.fileManager_.directoryModel.addEventListener( 1134 this.fileManager_.directoryModel.addEventListener(
1096 'directory-changed', 1135 'directory-changed',
1097 listener); 1136 listener);
1098 }; 1137 };
1099 1138
1100 /** @override */ 1139 /** @override */
1101 importer.RuntimeControllerEnvironment.prototype.addSelectionChangedListener = 1140 importer.RuntimeControllerEnvironment.prototype.addSelectionChangedListener =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 .catch(importer.getLogger().catcher('import-destination-provision')); 1208 .catch(importer.getLogger().catcher('import-destination-provision'));
1170 }; 1209 };
1171 1210
1172 /** @override */ 1211 /** @override */
1173 importer.RuntimeControllerEnvironment.prototype.showImportDestination = 1212 importer.RuntimeControllerEnvironment.prototype.showImportDestination =
1174 function(date) { 1213 function(date) {
1175 return this.getImportDestination(date) 1214 return this.getImportDestination(date)
1176 .then(this.revealDirectory_.bind(this)) 1215 .then(this.revealDirectory_.bind(this))
1177 .catch(importer.getLogger().catcher('import-destination-reveal')); 1216 .catch(importer.getLogger().catcher('import-destination-reveal'));
1178 }; 1217 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698