Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 var importer; | |
| 6 | |
| 7 /** | |
| 8 * Class representing the results of a scan operation. | |
| 9 * | |
| 10 * @interface | |
| 11 */ | |
| 12 importer.MediaScanner = function() {}; | |
|
fukino
2017/05/17 04:58:56
Can we remove duplicated definition of importer.Me
oka
2017/05/17 08:45:42
Done.
| |
| 13 | |
| 14 /** | |
| 15 * @typedef {function(!importer.ScanEvent, importer.ScanResult)} | |
| 16 */ | |
| 17 importer.ScanObserver; | |
| 18 | |
| 19 /** | |
| 20 * Initiates scanning. | |
| 21 * | |
| 22 * @param {!DirectoryEntry} directory | |
| 23 * @param {!importer.ScanMode} mode | |
| 24 * @return {!importer.ScanResult} ScanResult object representing the scan | |
| 25 * job both while in-progress and when completed. | |
| 26 */ | |
| 27 importer.MediaScanner.prototype.scanDirectory; | |
| 28 | |
| 29 /** | |
| 30 * Initiates scanning. | |
| 31 * | |
| 32 * @param {!Array<!FileEntry>} entries Must be non-empty, and all entires | |
| 33 * must be of a supported media type. Individually supplied files | |
| 34 * are not subject to deduplication. | |
| 35 * @param {!importer.ScanMode} mode The method to detect new files. | |
| 36 * @return {!importer.ScanResult} ScanResult object representing the scan | |
| 37 * job for the explicitly supplied entries. | |
| 38 */ | |
| 39 importer.MediaScanner.prototype.scanFiles; | |
| 40 | |
| 41 /** | |
| 42 * Adds an observer, which will be notified on scan events. | |
| 43 * | |
| 44 * @param {!importer.ScanObserver} observer | |
| 45 */ | |
| 46 importer.MediaScanner.prototype.addObserver; | |
| 47 | |
| 48 /** | |
| 49 * Remove a previously registered observer. | |
| 50 * | |
| 51 * @param {!importer.ScanObserver} observer | |
| 52 */ | |
| 53 importer.MediaScanner.prototype.removeObserver; | |
| 54 | |
| 55 /** | |
| 56 * Recursively scans through a list of given files and directories, and creates | |
| 57 * a list of media files. | |
| 58 * | |
| 59 * @constructor | |
| 60 * @struct | |
| 61 * @implements {importer.MediaScanner} | |
| 62 * | |
| 63 * @param {function(!FileEntry): !Promise.<string>} hashGenerator | |
| 64 * @param {function(!FileEntry, !importer.Destination, | |
| 65 * !importer.ScanMode): | |
| 66 * !Promise<!importer.Disposition>} dispositionChecker | |
| 67 * @param {!importer.DirectoryWatcherFactory} watcherFactory | |
| 68 */ | |
| 69 importer.DefaultMediaScanner = function( | |
|
fukino
2017/05/17 04:58:56
Do we need importer.DefaultMediaScanner in foregro
oka
2017/05/17 08:45:42
Removed.
| |
| 70 hashGenerator, dispositionChecker, watcherFactory) {}; | |
| 71 | |
| 72 /** @override */ | |
| 73 importer.DefaultMediaScanner.prototype.addObserver = function(observer) {}; | |
| 74 | |
| 75 /** @override */ | |
| 76 importer.DefaultMediaScanner.prototype.removeObserver = function(observer) {}; | |
| 77 | |
| 78 /** @override */ | |
| 79 importer.DefaultMediaScanner.prototype.scanDirectory = function( | |
| 80 directory, mode) {}; | |
| 81 | |
| 82 /** @override */ | |
| 83 importer.DefaultMediaScanner.prototype.scanFiles = function(entries, mode) {}; | |
| 84 | |
| 85 /** | |
| 86 * Class representing the results of a scan operation. | |
| 87 * | |
| 88 * @interface | |
| 89 */ | |
| 90 importer.ScanResult = function() {}; | |
|
fukino
2017/05/17 04:58:55
Can we remove duplicated definition from ui/file_m
oka
2017/05/17 08:45:42
Done.
| |
| 91 | |
| 92 /** | |
| 93 * @return {boolean} true if scanning is complete. | |
| 94 */ | |
| 95 importer.ScanResult.prototype.isFinal; | |
| 96 | |
| 97 /** | |
| 98 * Notifies the scan to stop working. Some in progress work | |
| 99 * may continue, but no new work will be undertaken. | |
| 100 */ | |
| 101 importer.ScanResult.prototype.cancel; | |
| 102 | |
| 103 /** | |
| 104 * @return {boolean} True if the scan has been canceled. Some | |
| 105 * work started prior to cancelation may still be ongoing. | |
| 106 */ | |
| 107 importer.ScanResult.prototype.canceled; | |
| 108 | |
| 109 /** | |
| 110 * @param {number} count Sets the total number of candidate entries | |
| 111 * that were checked while scanning. Used when determining | |
| 112 * total progress. | |
| 113 */ | |
| 114 importer.ScanResult.prototype.setCandidateCount; | |
| 115 | |
| 116 /** | |
| 117 * Event method called when a candidate has been processed. | |
| 118 * @param {number} count | |
| 119 */ | |
| 120 importer.ScanResult.prototype.onCandidatesProcessed; | |
| 121 | |
| 122 /** | |
| 123 * Returns all files entries discovered so far. The list will be | |
| 124 * complete only after scanning has completed and {@code isFinal} | |
| 125 * returns {@code true}. | |
| 126 * | |
| 127 * @return {!Array<!FileEntry>} | |
| 128 */ | |
| 129 importer.ScanResult.prototype.getFileEntries; | |
| 130 | |
| 131 /** | |
| 132 * Returns all files entry duplicates discovered so far. | |
| 133 * The list will be | |
| 134 * complete only after scanning has completed and {@code isFinal} | |
| 135 * returns {@code true}. | |
| 136 * | |
| 137 * Duplicates are files that were found during scanning, | |
| 138 * where not found in import history, and were matched to | |
| 139 * an existing entry either in the import destination, or | |
| 140 * to another entry within the scan itself. | |
| 141 * | |
| 142 * @return {!Array<!FileEntry>} | |
| 143 */ | |
| 144 importer.ScanResult.prototype.getDuplicateFileEntries; | |
| 145 | |
| 146 /** | |
| 147 * Returns a promise that fires when scanning is finished | |
| 148 * normally or has been canceled. | |
| 149 * | |
| 150 * @return {!Promise<!importer.ScanResult>} | |
| 151 */ | |
| 152 importer.ScanResult.prototype.whenFinal; | |
| 153 | |
| 154 /** | |
| 155 * @return {!importer.ScanResult.Statistics} | |
| 156 */ | |
| 157 importer.ScanResult.prototype.getStatistics; | |
| 158 | |
| 159 /** | |
| 160 * @typedef {{ | |
| 161 * scanDuration: number, | |
| 162 * newFileCount: number, | |
| 163 * duplicates: !Object<!importer.Disposition, number>, | |
| 164 * sizeBytes: number, | |
| 165 * candidates: { | |
| 166 * total: number, | |
| 167 * processed: number | |
| 168 * }, | |
| 169 * progress: number | |
| 170 * }} | |
| 171 */ | |
| 172 importer.ScanResult.Statistics; | |
| 173 | |
| 174 /** | |
| 175 * Results of a scan operation. The object is "live" in that data can and | |
| 176 * will change as the scan operation discovers files. | |
| 177 * | |
| 178 * <p>The scan is complete, and the object will become static once the | |
| 179 * {@code whenFinal} promise resolves. | |
| 180 * | |
| 181 * Note that classes implementing this should provide a read-only | |
| 182 * {@code name} field. | |
| 183 * | |
| 184 * @constructor | |
| 185 * @struct | |
| 186 * @implements {importer.ScanResult} | |
| 187 * | |
| 188 * @param {importer.ScanMode} mode The scan mode applied for finding new files. | |
| 189 * @param {function(!FileEntry): !Promise.<string>} hashGenerator Hash-code | |
| 190 * generator used to dedupe within the scan results itself. | |
| 191 */ | |
| 192 importer.DefaultScanResult = function(mode, hashGenerator) {}; | |
|
fukino
2017/05/17 04:58:56
importer.DefaultScanResult is not used from foregr
oka
2017/05/17 08:45:42
Done.
| |
| 193 | |
| 194 /** @struct */ | |
| 195 importer.DefaultScanResult.prototype = { | |
| 196 /** @return {string} */ | |
| 197 get name() {}, | |
| 198 | |
| 199 /** @return {function()} */ | |
| 200 get resolve() {}, | |
| 201 | |
| 202 /** @return {function(*=)} */ | |
| 203 get reject() {} | |
| 204 }; | |
| 205 | |
| 206 /** @override */ | |
| 207 importer.DefaultScanResult.prototype.isFinal = function() {}; | |
| 208 | |
| 209 /** @override */ | |
| 210 importer.DefaultScanResult.prototype.setCandidateCount = function(count) {}; | |
| 211 | |
| 212 /** @override */ | |
| 213 importer.DefaultScanResult.prototype.onCandidatesProcessed = function(count) {}; | |
| 214 | |
| 215 /** @override */ | |
| 216 importer.DefaultScanResult.prototype.getFileEntries = function() {}; | |
| 217 | |
| 218 /** @override */ | |
| 219 importer.DefaultScanResult.prototype.getDuplicateFileEntries = function() {}; | |
| 220 | |
| 221 /** @override */ | |
| 222 importer.DefaultScanResult.prototype.whenFinal = function() {}; | |
| 223 | |
| 224 /** @override */ | |
| 225 importer.DefaultScanResult.prototype.cancel = function() {}; | |
| 226 | |
| 227 /** @override */ | |
| 228 importer.DefaultScanResult.prototype.canceled = function() {}; | |
| 229 | |
| 230 /** | |
| 231 * Adds a file to results. | |
| 232 * | |
| 233 * @param {!FileEntry} entry | |
| 234 * @return {!Promise.<boolean>} True if the file as added, false if it was | |
| 235 * rejected as a dupe. | |
| 236 */ | |
| 237 importer.DefaultScanResult.prototype.addFileEntry = function(entry) {}; | |
| 238 | |
| 239 /** | |
| 240 * Logs the fact that a duplicate file entry was discovered during the scan. | |
| 241 * @param {!FileEntry} entry | |
| 242 * @param {!importer.Disposition} disposition | |
| 243 */ | |
| 244 importer.DefaultScanResult.prototype.addDuplicateEntry = function( | |
| 245 entry, disposition) {}; | |
| 246 | |
| 247 /** @override */ | |
| 248 importer.DefaultScanResult.prototype.getStatistics = function() {}; | |
| 249 | |
| 250 /** | |
| 251 * Watcher for directories. | |
| 252 * @interface | |
| 253 */ | |
| 254 importer.DirectoryWatcher = function() {}; | |
|
fukino
2017/05/17 04:58:56
ditto
oka
2017/05/17 08:45:42
Done.
| |
| 255 | |
| 256 /** | |
| 257 * Registers new directory to be watched. | |
| 258 * @param {!DirectoryEntry} entry | |
| 259 */ | |
| 260 importer.DirectoryWatcher.prototype.addDirectory = function(entry) {}; | |
| 261 | |
| 262 /** | |
| 263 * @typedef {function()} | |
| 264 */ | |
| 265 importer.DirectoryWatcherFactoryCallback; | |
| 266 | |
| 267 /** | |
| 268 * @typedef {function(importer.DirectoryWatcherFactoryCallback): | |
| 269 * !importer.DirectoryWatcher} | |
| 270 */ | |
| 271 importer.DirectoryWatcherFactory; | |
| 272 | |
| 273 /** | |
| 274 * Watcher for directories. | |
| 275 * @param {function()} callback Callback to be invoked when one of watched | |
| 276 * directories is changed. | |
| 277 * @implements {importer.DirectoryWatcher} | |
| 278 * @constructor | |
| 279 */ | |
| 280 importer.DefaultDirectoryWatcher = function(callback) {}; | |
|
fukino
2017/05/17 04:58:56
ditto
oka
2017/05/17 08:45:42
Done.
| |
| 281 | |
| 282 /** | |
| 283 * Creates new directory watcher. | |
| 284 * @param {function()} callback Callback to be invoked when one of watched | |
| 285 * directories is changed. | |
| 286 * @return {!importer.DirectoryWatcher} | |
| 287 */ | |
| 288 importer.DefaultDirectoryWatcher.create = function(callback) {}; | |
| 289 | |
| 290 /** | |
| 291 * Registers new directory to be watched. | |
| 292 * @param {!DirectoryEntry} entry | |
| 293 */ | |
| 294 importer.DefaultDirectoryWatcher.prototype.addDirectory = function(entry) {}; | |
| OLD | NEW |