| 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() {}; |
| 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 * Class representing the results of a scan operation. |
| 57 * |
| 58 * @interface |
| 59 */ |
| 60 importer.ScanResult = function() {}; |
| 61 |
| 62 /** |
| 63 * @return {boolean} true if scanning is complete. |
| 64 */ |
| 65 importer.ScanResult.prototype.isFinal; |
| 66 |
| 67 /** |
| 68 * Notifies the scan to stop working. Some in progress work |
| 69 * may continue, but no new work will be undertaken. |
| 70 */ |
| 71 importer.ScanResult.prototype.cancel; |
| 72 |
| 73 /** |
| 74 * @return {boolean} True if the scan has been canceled. Some |
| 75 * work started prior to cancelation may still be ongoing. |
| 76 */ |
| 77 importer.ScanResult.prototype.canceled; |
| 78 |
| 79 /** |
| 80 * @param {number} count Sets the total number of candidate entries |
| 81 * that were checked while scanning. Used when determining |
| 82 * total progress. |
| 83 */ |
| 84 importer.ScanResult.prototype.setCandidateCount; |
| 85 |
| 86 /** |
| 87 * Event method called when a candidate has been processed. |
| 88 * @param {number} count |
| 89 */ |
| 90 importer.ScanResult.prototype.onCandidatesProcessed; |
| 91 |
| 92 /** |
| 93 * Returns all files entries discovered so far. The list will be |
| 94 * complete only after scanning has completed and {@code isFinal} |
| 95 * returns {@code true}. |
| 96 * |
| 97 * @return {!Array<!FileEntry>} |
| 98 */ |
| 99 importer.ScanResult.prototype.getFileEntries; |
| 100 |
| 101 /** |
| 102 * Returns all files entry duplicates discovered so far. |
| 103 * The list will be |
| 104 * complete only after scanning has completed and {@code isFinal} |
| 105 * returns {@code true}. |
| 106 * |
| 107 * Duplicates are files that were found during scanning, |
| 108 * where not found in import history, and were matched to |
| 109 * an existing entry either in the import destination, or |
| 110 * to another entry within the scan itself. |
| 111 * |
| 112 * @return {!Array<!FileEntry>} |
| 113 */ |
| 114 importer.ScanResult.prototype.getDuplicateFileEntries; |
| 115 |
| 116 /** |
| 117 * Returns a promise that fires when scanning is finished |
| 118 * normally or has been canceled. |
| 119 * |
| 120 * @return {!Promise<!importer.ScanResult>} |
| 121 */ |
| 122 importer.ScanResult.prototype.whenFinal; |
| 123 |
| 124 /** |
| 125 * @return {!importer.ScanResult.Statistics} |
| 126 */ |
| 127 importer.ScanResult.prototype.getStatistics; |
| 128 |
| 129 /** |
| 130 * @typedef {{ |
| 131 * scanDuration: number, |
| 132 * newFileCount: number, |
| 133 * duplicates: !Object<!importer.Disposition, number>, |
| 134 * sizeBytes: number, |
| 135 * candidates: { |
| 136 * total: number, |
| 137 * processed: number |
| 138 * }, |
| 139 * progress: number |
| 140 * }} |
| 141 */ |
| 142 importer.ScanResult.Statistics; |
| OLD | NEW |