Chromium Code Reviews| Index: ui/file_manager/externs/background/media_scanner.js |
| diff --git a/ui/file_manager/externs/background/media_scanner.js b/ui/file_manager/externs/background/media_scanner.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..364a28afc8d5e154c2f33a461f6f038f6ffb2013 |
| --- /dev/null |
| +++ b/ui/file_manager/externs/background/media_scanner.js |
| @@ -0,0 +1,294 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +var importer; |
| + |
| +/** |
| + * Class representing the results of a scan operation. |
| + * |
| + * @interface |
| + */ |
| +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.
|
| + |
| +/** |
| + * @typedef {function(!importer.ScanEvent, importer.ScanResult)} |
| + */ |
| +importer.ScanObserver; |
| + |
| +/** |
| + * Initiates scanning. |
| + * |
| + * @param {!DirectoryEntry} directory |
| + * @param {!importer.ScanMode} mode |
| + * @return {!importer.ScanResult} ScanResult object representing the scan |
| + * job both while in-progress and when completed. |
| + */ |
| +importer.MediaScanner.prototype.scanDirectory; |
| + |
| +/** |
| + * Initiates scanning. |
| + * |
| + * @param {!Array<!FileEntry>} entries Must be non-empty, and all entires |
| + * must be of a supported media type. Individually supplied files |
| + * are not subject to deduplication. |
| + * @param {!importer.ScanMode} mode The method to detect new files. |
| + * @return {!importer.ScanResult} ScanResult object representing the scan |
| + * job for the explicitly supplied entries. |
| + */ |
| +importer.MediaScanner.prototype.scanFiles; |
| + |
| +/** |
| + * Adds an observer, which will be notified on scan events. |
| + * |
| + * @param {!importer.ScanObserver} observer |
| + */ |
| +importer.MediaScanner.prototype.addObserver; |
| + |
| +/** |
| + * Remove a previously registered observer. |
| + * |
| + * @param {!importer.ScanObserver} observer |
| + */ |
| +importer.MediaScanner.prototype.removeObserver; |
| + |
| +/** |
| + * Recursively scans through a list of given files and directories, and creates |
| + * a list of media files. |
| + * |
| + * @constructor |
| + * @struct |
| + * @implements {importer.MediaScanner} |
| + * |
| + * @param {function(!FileEntry): !Promise.<string>} hashGenerator |
| + * @param {function(!FileEntry, !importer.Destination, |
| + * !importer.ScanMode): |
| + * !Promise<!importer.Disposition>} dispositionChecker |
| + * @param {!importer.DirectoryWatcherFactory} watcherFactory |
| + */ |
| +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.
|
| + hashGenerator, dispositionChecker, watcherFactory) {}; |
| + |
| +/** @override */ |
| +importer.DefaultMediaScanner.prototype.addObserver = function(observer) {}; |
| + |
| +/** @override */ |
| +importer.DefaultMediaScanner.prototype.removeObserver = function(observer) {}; |
| + |
| +/** @override */ |
| +importer.DefaultMediaScanner.prototype.scanDirectory = function( |
| + directory, mode) {}; |
| + |
| +/** @override */ |
| +importer.DefaultMediaScanner.prototype.scanFiles = function(entries, mode) {}; |
| + |
| +/** |
| + * Class representing the results of a scan operation. |
| + * |
| + * @interface |
| + */ |
| +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.
|
| + |
| +/** |
| + * @return {boolean} true if scanning is complete. |
| + */ |
| +importer.ScanResult.prototype.isFinal; |
| + |
| +/** |
| + * Notifies the scan to stop working. Some in progress work |
| + * may continue, but no new work will be undertaken. |
| + */ |
| +importer.ScanResult.prototype.cancel; |
| + |
| +/** |
| + * @return {boolean} True if the scan has been canceled. Some |
| + * work started prior to cancelation may still be ongoing. |
| + */ |
| +importer.ScanResult.prototype.canceled; |
| + |
| +/** |
| + * @param {number} count Sets the total number of candidate entries |
| + * that were checked while scanning. Used when determining |
| + * total progress. |
| + */ |
| +importer.ScanResult.prototype.setCandidateCount; |
| + |
| +/** |
| + * Event method called when a candidate has been processed. |
| + * @param {number} count |
| + */ |
| +importer.ScanResult.prototype.onCandidatesProcessed; |
| + |
| +/** |
| + * Returns all files entries discovered so far. The list will be |
| + * complete only after scanning has completed and {@code isFinal} |
| + * returns {@code true}. |
| + * |
| + * @return {!Array<!FileEntry>} |
| + */ |
| +importer.ScanResult.prototype.getFileEntries; |
| + |
| +/** |
| + * Returns all files entry duplicates discovered so far. |
| + * The list will be |
| + * complete only after scanning has completed and {@code isFinal} |
| + * returns {@code true}. |
| + * |
| + * Duplicates are files that were found during scanning, |
| + * where not found in import history, and were matched to |
| + * an existing entry either in the import destination, or |
| + * to another entry within the scan itself. |
| + * |
| + * @return {!Array<!FileEntry>} |
| + */ |
| +importer.ScanResult.prototype.getDuplicateFileEntries; |
| + |
| +/** |
| + * Returns a promise that fires when scanning is finished |
| + * normally or has been canceled. |
| + * |
| + * @return {!Promise<!importer.ScanResult>} |
| + */ |
| +importer.ScanResult.prototype.whenFinal; |
| + |
| +/** |
| + * @return {!importer.ScanResult.Statistics} |
| + */ |
| +importer.ScanResult.prototype.getStatistics; |
| + |
| +/** |
| + * @typedef {{ |
| + * scanDuration: number, |
| + * newFileCount: number, |
| + * duplicates: !Object<!importer.Disposition, number>, |
| + * sizeBytes: number, |
| + * candidates: { |
| + * total: number, |
| + * processed: number |
| + * }, |
| + * progress: number |
| + * }} |
| + */ |
| +importer.ScanResult.Statistics; |
| + |
| +/** |
| + * Results of a scan operation. The object is "live" in that data can and |
| + * will change as the scan operation discovers files. |
| + * |
| + * <p>The scan is complete, and the object will become static once the |
| + * {@code whenFinal} promise resolves. |
| + * |
| + * Note that classes implementing this should provide a read-only |
| + * {@code name} field. |
| + * |
| + * @constructor |
| + * @struct |
| + * @implements {importer.ScanResult} |
| + * |
| + * @param {importer.ScanMode} mode The scan mode applied for finding new files. |
| + * @param {function(!FileEntry): !Promise.<string>} hashGenerator Hash-code |
| + * generator used to dedupe within the scan results itself. |
| + */ |
| +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.
|
| + |
| +/** @struct */ |
| +importer.DefaultScanResult.prototype = { |
| + /** @return {string} */ |
| + get name() {}, |
| + |
| + /** @return {function()} */ |
| + get resolve() {}, |
| + |
| + /** @return {function(*=)} */ |
| + get reject() {} |
| +}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.isFinal = function() {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.setCandidateCount = function(count) {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.onCandidatesProcessed = function(count) {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.getFileEntries = function() {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.getDuplicateFileEntries = function() {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.whenFinal = function() {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.cancel = function() {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.canceled = function() {}; |
| + |
| +/** |
| + * Adds a file to results. |
| + * |
| + * @param {!FileEntry} entry |
| + * @return {!Promise.<boolean>} True if the file as added, false if it was |
| + * rejected as a dupe. |
| + */ |
| +importer.DefaultScanResult.prototype.addFileEntry = function(entry) {}; |
| + |
| +/** |
| + * Logs the fact that a duplicate file entry was discovered during the scan. |
| + * @param {!FileEntry} entry |
| + * @param {!importer.Disposition} disposition |
| + */ |
| +importer.DefaultScanResult.prototype.addDuplicateEntry = function( |
| + entry, disposition) {}; |
| + |
| +/** @override */ |
| +importer.DefaultScanResult.prototype.getStatistics = function() {}; |
| + |
| +/** |
| + * Watcher for directories. |
| + * @interface |
| + */ |
| +importer.DirectoryWatcher = function() {}; |
|
fukino
2017/05/17 04:58:56
ditto
oka
2017/05/17 08:45:42
Done.
|
| + |
| +/** |
| + * Registers new directory to be watched. |
| + * @param {!DirectoryEntry} entry |
| + */ |
| +importer.DirectoryWatcher.prototype.addDirectory = function(entry) {}; |
| + |
| +/** |
| + * @typedef {function()} |
| + */ |
| +importer.DirectoryWatcherFactoryCallback; |
| + |
| +/** |
| + * @typedef {function(importer.DirectoryWatcherFactoryCallback): |
| + * !importer.DirectoryWatcher} |
| + */ |
| +importer.DirectoryWatcherFactory; |
| + |
| +/** |
| + * Watcher for directories. |
| + * @param {function()} callback Callback to be invoked when one of watched |
| + * directories is changed. |
| + * @implements {importer.DirectoryWatcher} |
| + * @constructor |
| + */ |
| +importer.DefaultDirectoryWatcher = function(callback) {}; |
|
fukino
2017/05/17 04:58:56
ditto
oka
2017/05/17 08:45:42
Done.
|
| + |
| +/** |
| + * Creates new directory watcher. |
| + * @param {function()} callback Callback to be invoked when one of watched |
| + * directories is changed. |
| + * @return {!importer.DirectoryWatcher} |
| + */ |
| +importer.DefaultDirectoryWatcher.create = function(callback) {}; |
| + |
| +/** |
| + * Registers new directory to be watched. |
| + * @param {!DirectoryEntry} entry |
| + */ |
| +importer.DefaultDirectoryWatcher.prototype.addDirectory = function(entry) {}; |