1 // Copyright (c) 2012 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.
6 * Scanner of the entries.
9 function ContentScanner() {
10 this.cancelled_ = false;
14 * Starts to scan the entries. For example, starts to read the entries in a
15 * directory, or starts to search with some query on a file system.
16 * Derived classes must override this method.
18 * @param {function(Array.<Entry>)} entriesCallback Called when some chunk of
19 * entries are read. This can be called a couple of times until the
21 * @param {function()} successCallback Called when the scan is completed
23 * @param {function(DOMError)} errorCallback Called an error occurs.
25 ContentScanner.prototype.scan = function(
26 entriesCallback, successCallback, errorCallback) {
30 * Request cancelling of the running scan. When the cancelling is done,
31 * an error will be reported from errorCallback passed to scan().
33 ContentScanner.prototype.cancel = function() {
34 this.cancelled_ = true;
38 * Scanner of the entries in a directory.
39 * @param {DirectoryEntry} entry The directory to be read.
41 * @extends {ContentScanner}
43 function DirectoryContentScanner(entry) {
44 ContentScanner.call(this);
49 * Extends ContentScanner.
51 DirectoryContentScanner.prototype.__proto__ = ContentScanner.prototype;
54 * Starts to read the entries in the directory.
57 DirectoryContentScanner.prototype.scan = function(
58 entriesCallback, successCallback, errorCallback) {
59 if (!this.entry_ || util.isFakeEntry(this.entry_)) {
60 // If entry is not specified or a fake, we cannot read it.
61 errorCallback(util.createDOMError(
62 util.FileError.INVALID_MODIFICATION_ERR));
66 metrics.startInterval('DirectoryScan');
67 var reader = this.entry_.createReader();
68 var readEntries = function() {
71 if (this.cancelled_) {
72 errorCallback(util.createDOMError(util.FileError.ABORT_ERR));
76 if (entries.length === 0) {
77 // All entries are read.
78 metrics.recordInterval('DirectoryScan');
83 entriesCallback(entries);
92 * Scanner of the entries for the search results on Drive File System.
93 * @param {string} query The query string.
95 * @extends {ContentScanner}
97 function DriveSearchContentScanner(query) {
98 ContentScanner.call(this);
103 * Extends ContentScanner.
105 DriveSearchContentScanner.prototype.__proto__ = ContentScanner.prototype;
108 * Delay in milliseconds to be used for drive search scan, in order to reduce
109 * the number of server requests while user is typing the query.
114 DriveSearchContentScanner.SCAN_DELAY_ = 200;
117 * Maximum number of results which is shown on the search.
122 DriveSearchContentScanner.MAX_RESULTS_ = 100;
125 * Starts to search on Drive File System.
128 DriveSearchContentScanner.prototype.scan = function(
129 entriesCallback, successCallback, errorCallback) {
130 var numReadEntries = 0;
131 var readEntries = function(nextFeed) {
132 chrome.fileManagerPrivate.searchDrive(
133 {query: this.query_, nextFeed: nextFeed},
134 function(entries, nextFeed) {
135 if (this.cancelled_) {
136 errorCallback(util.createDOMError(util.FileError.ABORT_ERR));
140 // TODO(tbarzic): Improve error handling.
142 console.error('Drive search encountered an error.');
143 errorCallback(util.createDOMError(
144 util.FileError.INVALID_MODIFICATION_ERR));
148 var numRemainingEntries =
149 DriveSearchContentScanner.MAX_RESULTS_ - numReadEntries;
150 if (entries.length >= numRemainingEntries) {
151 // The limit is hit, so quit the scan here.
152 entries = entries.slice(0, numRemainingEntries);
156 numReadEntries += entries.length;
157 if (entries.length > 0)
158 entriesCallback(entries);
163 readEntries(nextFeed);
167 // Let's give another search a chance to cancel us before we begin.
170 // Check cancelled state before read the entries.
171 if (this.cancelled_) {
172 errorCallback(util.createDOMError(util.FileError.ABORT_ERR));
177 DriveSearchContentScanner.SCAN_DELAY_);
181 * Scanner of the entries of the file name search on the directory tree, whose
183 * @param {DirectoryEntry} entry The root of the search target directory tree.
184 * @param {string} query The query of the search.
186 * @extends {ContentScanner}
188 function LocalSearchContentScanner(entry, query) {
189 ContentScanner.call(this);
191 this.query_ = query.toLowerCase();
195 * Extends ContentScanner.
197 LocalSearchContentScanner.prototype.__proto__ = ContentScanner.prototype;
200 * Starts the file name search.
203 LocalSearchContentScanner.prototype.scan = function(
204 entriesCallback, successCallback, errorCallback) {
205 var numRunningTasks = 0;
207 var maybeRunCallback = function() {
208 if (numRunningTasks === 0) {
210 errorCallback(util.createDOMError(util.FileError.ABORT_ERR));
212 errorCallback(error);
218 var processEntry = function(entry) {
220 var onError = function(fileError) {
227 var onSuccess = function(entries) {
228 if (this.cancelled_ || error || entries.length === 0) {
234 // Filters by the query, and if found, run entriesCallback.
235 var foundEntries = entries.filter(function(entry) {
236 return entry.name.toLowerCase().indexOf(this.query_) >= 0;
238 if (foundEntries.length > 0)
239 entriesCallback(foundEntries);
241 // Start to process sub directories.
242 for (var i = 0; i < entries.length; i++) {
243 if (entries[i].isDirectory)
244 processEntry(entries[i]);
247 // Read remaining entries.
248 reader.readEntries(onSuccess, onError);
251 var reader = entry.createReader();
252 reader.readEntries(onSuccess, onError);
255 processEntry(this.entry_);
259 * Scanner of the entries for the metadata search on Drive File System.
260 * @param {!DriveMetadataSearchContentScanner.SearchType} searchType The option
263 * @extends {ContentScanner}
265 function DriveMetadataSearchContentScanner(searchType) {
266 ContentScanner.call(this);
267 this.searchType_ = searchType;
271 * Extends ContentScanner.
273 DriveMetadataSearchContentScanner.prototype.__proto__ =
274 ContentScanner.prototype;
277 * The search types on the Drive File System.
280 DriveMetadataSearchContentScanner.SearchType = {
282 SEARCH_SHARED_WITH_ME: 'SHARED_WITH_ME',
283 SEARCH_RECENT_FILES: 'EXCLUDE_DIRECTORIES',
284 SEARCH_OFFLINE: 'OFFLINE'
286 Object.freeze(DriveMetadataSearchContentScanner.SearchType);
289 * Starts to metadata-search on Drive File System.
292 DriveMetadataSearchContentScanner.prototype.scan = function(
293 entriesCallback, successCallback, errorCallback) {
294 chrome.fileManagerPrivate.searchDriveMetadata(
295 {query: '', types: this.searchType_, maxResults: 500},
297 if (this.cancelled_) {
298 errorCallback(util.createDOMError(util.FileError.ABORT_ERR));
303 console.error('Drive search encountered an error.');
304 errorCallback(util.createDOMError(
305 util.FileError.INVALID_MODIFICATION_ERR));
309 var entries = results.map(function(result) { return result.entry; });
310 if (entries.length > 0)
311 entriesCallback(entries);
317 * This class manages filters and determines a file should be shown or not.
318 * When filters are changed, a 'changed' event is fired.
320 * @param {MetadataCache} metadataCache Metadata cache service.
321 * @param {boolean} showHidden If files starting with '.' or ending with
322 * '.crdownlaod' are shown.
324 * @extends {cr.EventTarget}
326 function FileFilter(metadataCache, showHidden) {
328 * @type {MetadataCache}
331 this.metadataCache_ = metadataCache;
334 * @type {Object.<string, Function>}
338 this.setFilterHidden(!showHidden);
340 // Do not show entries marked as 'deleted'.
341 this.addFilter('deleted', function(entry) {
342 var internal = /** @type {{deleted}} */
343 (this.metadataCache_.getCached(entry, 'internal'));
344 return !(internal && internal.deleted);
349 * FileFilter extends cr.EventTarget.
351 FileFilter.prototype = {__proto__: cr.EventTarget.prototype};
354 * @param {string} name Filter identifier.
355 * @param {function(Entry)} callback A filter — a function receiving an Entry,
356 * and returning bool.
358 FileFilter.prototype.addFilter = function(name, callback) {
359 this.filters_[name] = callback;
360 cr.dispatchSimpleEvent(this, 'changed');
364 * @param {string} name Filter identifier.
366 FileFilter.prototype.removeFilter = function(name) {
367 delete this.filters_[name];
368 cr.dispatchSimpleEvent(this, 'changed');
372 * @param {boolean} value If do not show hidden files.
374 FileFilter.prototype.setFilterHidden = function(value) {
375 var regexpCrdownloadExtension = /\.crdownload$/i;
380 return entry.name.substr(0, 1) !== '.' &&
381 !regexpCrdownloadExtension.test(entry.name);
385 this.removeFilter('hidden');
390 * @return {boolean} If the files with names starting with "." are not shown.
392 FileFilter.prototype.isFilterHiddenOn = function() {
393 return 'hidden' in this.filters_;
397 * @param {Entry} entry File entry.
398 * @return {boolean} True if the file should be shown, false otherwise.
400 FileFilter.prototype.filter = function(entry) {
401 for (var name in this.filters_) {
402 if (!this.filters_[name](entry))
410 * @param {MetadataCache} metadataCache Metadata cache.
412 * @extends {cr.ui.ArrayDataModel}
414 function FileListModel(metadataCache) {
415 cr.ui.ArrayDataModel.call(this, []);
419 * @type {MetadataCache}
422 this.metadataCache_ = metadataCache;
424 // Initialize compare functions.
425 this.setCompareFunction('name',
426 /** @type {function(*, *): number} */ (util.compareName));
427 this.setCompareFunction('modificationTime',
428 /** @type {function(*, *): number} */ (this.compareMtime_.bind(this)));
429 this.setCompareFunction('size',
430 /** @type {function(*, *): number} */ (this.compareSize_.bind(this)));
431 this.setCompareFunction('type',
432 /** @type {function(*, *): number} */ (this.compareType_.bind(this)));
435 FileListModel.prototype = {
436 __proto__: cr.ui.ArrayDataModel.prototype
440 * Compare by mtime first, then by name.
441 * @param {Entry} a First entry.
442 * @param {Entry} b Second entry.
443 * @return {number} Compare result.
446 FileListModel.prototype.compareMtime_ = function(a, b) {
447 var aCachedFilesystem = this.metadataCache_.getCached(a, 'filesystem');
448 var aTime = aCachedFilesystem ? aCachedFilesystem.modificationTime : 0;
450 var bCachedFilesystem = this.metadataCache_.getCached(b, 'filesystem');
451 var bTime = bCachedFilesystem ? bCachedFilesystem.modificationTime : 0;
459 return util.compareName(a, b);
463 * Compare by size first, then by name.
464 * @param {Entry} a First entry.
465 * @param {Entry} b Second entry.
466 * @return {number} Compare result.
469 FileListModel.prototype.compareSize_ = function(a, b) {
470 var aCachedFilesystem = this.metadataCache_.getCached(a, 'filesystem');
471 var aSize = aCachedFilesystem ? aCachedFilesystem.size : 0;
473 var bCachedFilesystem = this.metadataCache_.getCached(b, 'filesystem');
474 var bSize = bCachedFilesystem ? bCachedFilesystem.size : 0;
476 return aSize !== bSize ? aSize - bSize : util.compareName(a, b);
480 * Compare by type first, then by subtype and then by name.
481 * @param {Entry} a First entry.
482 * @param {Entry} b Second entry.
483 * @return {number} Compare result.
486 FileListModel.prototype.compareType_ = function(a, b) {
487 // Directories precede files.
488 if (a.isDirectory !== b.isDirectory)
489 return Number(b.isDirectory) - Number(a.isDirectory);
491 var aType = FileType.typeToString(FileType.getType(a));
492 var bType = FileType.typeToString(FileType.getType(b));
494 var result = util.collator.compare(aType, bType);
495 return result !== 0 ? result : util.compareName(a, b);
499 * A context of DirectoryContents.
500 * TODO(yoshiki): remove this. crbug.com/224869.
502 * @param {FileFilter} fileFilter The file-filter context.
503 * @param {MetadataCache} metadataCache Metadata cache service.
506 function FileListContext(fileFilter, metadataCache) {
508 * @type {FileListModel}
510 this.fileList = new FileListModel(metadataCache);
513 * @type {MetadataCache}
515 this.metadataCache = metadataCache;
520 this.fileFilter = fileFilter;
524 * This class is responsible for scanning directory (or search results),
525 * and filling the fileList. Different descendants handle various types of
526 * directory contents shown: basic directory, drive search results, local search
528 * TODO(hidehiko): Remove EventTarget from this.
530 * @param {FileListContext} context The file list context.
531 * @param {boolean} isSearch True for search directory contents, otherwise
533 * @param {DirectoryEntry} directoryEntry The entry of the current directory.
534 * @param {function():ContentScanner} scannerFactory The factory to create
535 * ContentScanner instance.
537 * @extends {cr.EventTarget}
539 function DirectoryContents(context,
543 this.context_ = context;
544 this.fileList_ = context.fileList;
546 this.isSearch_ = isSearch;
547 this.directoryEntry_ = directoryEntry;
549 this.scannerFactory_ = scannerFactory;
550 this.scanner_ = null;
551 this.processNewEntriesQueue_ = new AsyncUtil.Queue();
552 this.scanCancelled_ = false;
554 this.lastSpaceInMetadataCache_ = 0;
558 * DirectoryContents extends cr.EventTarget.
560 DirectoryContents.prototype.__proto__ = cr.EventTarget.prototype;
563 * Create the copy of the object, but without scan started.
564 * @return {DirectoryContents} Object copy.
566 DirectoryContents.prototype.clone = function() {
567 return new DirectoryContents(
570 this.directoryEntry_,
571 this.scannerFactory_);
575 * Disposes the reserved metadata cache.
577 DirectoryContents.prototype.dispose = function() {
578 this.context_.metadataCache.resizeBy(-this.lastSpaceInMetadataCache_);
579 // Though the lastSpaceInMetadataCache_ is not supposed to be referred after
580 // dispose(), keep it synced with requested cache size just in case.
581 this.lastSpaceInMetadataCache_ = 0;
585 * Make a space for current directory size in the metadata cache.
587 * @param {number} size The cache size to be set.
590 DirectoryContents.prototype.makeSpaceInMetadataCache_ = function(size) {
591 this.context_.metadataCache.resizeBy(size - this.lastSpaceInMetadataCache_);
592 this.lastSpaceInMetadataCache_ = size;
596 * Use a given fileList instead of the fileList from the context.
597 * @param {(!Array|!cr.ui.ArrayDataModel)} fileList The new file list.
599 DirectoryContents.prototype.setFileList = function(fileList) {
600 if (fileList instanceof cr.ui.ArrayDataModel)
601 this.fileList_ = fileList;
603 this.fileList_ = new cr.ui.ArrayDataModel(fileList);
604 this.makeSpaceInMetadataCache_(this.fileList_.length);
608 * Use the filelist from the context and replace its contents with the entries
609 * from the current fileList.
611 DirectoryContents.prototype.replaceContextFileList = function() {
612 if (this.context_.fileList !== this.fileList_) {
613 var spliceArgs = this.fileList_.slice();
614 var fileList = this.context_.fileList;
615 spliceArgs.unshift(0, fileList.length);
616 fileList.splice.apply(fileList, spliceArgs);
617 this.fileList_ = fileList;
618 this.makeSpaceInMetadataCache_(this.fileList_.length);
623 * @return {boolean} If the scan is active.
625 DirectoryContents.prototype.isScanning = function() {
626 return this.scanner_ || this.processNewEntriesQueue_.isRunning();
630 * @return {boolean} True if search results (drive or local).
632 DirectoryContents.prototype.isSearch = function() {
633 return this.isSearch_;
637 * @return {DirectoryEntry} A DirectoryEntry for current directory. In case of
638 * search -- the top directory from which search is run.
640 DirectoryContents.prototype.getDirectoryEntry = function() {
641 return this.directoryEntry_;
645 * Start directory scan/search operation. Either 'scan-completed' or
646 * 'scan-failed' event will be fired upon completion.
648 * @param {boolean} refresh True to refresh metadata, or false to use cached
651 DirectoryContents.prototype.scan = function(refresh) {
653 * Invoked when the scanning is completed successfully.
654 * @this {DirectoryContents}
656 function completionCallback() {
657 this.onScanFinished_();
658 this.onScanCompleted_();
662 * Invoked when the scanning is finished but is not completed due to error.
663 * @this {DirectoryContents}
665 function errorCallback() {
666 this.onScanFinished_();
670 // TODO(hidehiko,mtomasz): this scan method must be called at most once.
671 // Remove such a limitation.
672 this.scanner_ = this.scannerFactory_();
673 this.scanner_.scan(this.onNewEntries_.bind(this, refresh),
674 completionCallback.bind(this),
675 errorCallback.bind(this));
679 * Adds/removes/updates items of file list.
680 * @param {Array.<Entry>} updatedEntries Entries of updated/added files.
681 * @param {Array.<string>} removedUrls URLs of removed files.
683 DirectoryContents.prototype.update = function(updatedEntries, removedUrls) {
685 for (var i = 0; i < removedUrls.length; i++) {
686 removedMap[removedUrls[i]] = true;
690 for (var i = 0; i < updatedEntries.length; i++) {
691 updatedMap[updatedEntries[i].toURL()] = updatedEntries[i];
694 var updatedList = [];
695 for (var i = 0; i < this.fileList_.length; i++) {
696 var url = this.fileList_.item(i).toURL();
698 if (url in removedMap) {
699 this.fileList_.splice(i, 1);
704 if (url in updatedMap) {
705 updatedList.push(updatedMap[url]);
706 delete updatedMap[url];
711 for (var url in updatedMap) {
712 addedList.push(updatedMap[url]);
715 if (removedUrls.length > 0)
716 this.fileList_.metadataCache_.clearByUrl(removedUrls, '*');
718 this.prefetchMetadata(updatedList, true, function() {
719 this.onNewEntries_(true, addedList);
720 this.onScanFinished_();
721 this.onScanCompleted_();
726 * Cancels the running scan.
728 DirectoryContents.prototype.cancelScan = function() {
729 if (this.scanCancelled_)
731 this.scanCancelled_ = true;
733 this.scanner_.cancel();
735 this.onScanFinished_();
737 this.processNewEntriesQueue_.cancel();
738 cr.dispatchSimpleEvent(this, 'scan-cancelled');
742 * Called when the scanning by scanner_ is done, even when the scanning is
743 * succeeded or failed. This is called before completion (or error) callback.
747 DirectoryContents.prototype.onScanFinished_ = function() {
748 this.scanner_ = null;
750 this.processNewEntriesQueue_.run(function(callback) {
751 // TODO(yoshiki): Here we should fire the update event of changed
752 // items. Currently we have a method this.fileList_.updateIndex() to
753 // fire an event, but this method takes only 1 argument and invokes sort
754 // one by one. It is obviously time wasting. Instead, we call sort
756 // In future, we should implement a good method like updateIndexes and
758 var status = this.fileList_.sortStatus;
760 this.fileList_.sort(status.field, status.direction);
767 * Called when the scanning by scanner_ is succeeded.
770 DirectoryContents.prototype.onScanCompleted_ = function() {
771 if (this.scanCancelled_)
774 this.processNewEntriesQueue_.run(function(callback) {
775 // Call callback first, so isScanning() returns false in the event handlers.
778 cr.dispatchSimpleEvent(this, 'scan-completed');
783 * Called in case scan has failed. Should send the event.
786 DirectoryContents.prototype.onScanError_ = function() {
787 if (this.scanCancelled_)
790 this.processNewEntriesQueue_.run(function(callback) {
791 // Call callback first, so isScanning() returns false in the event handlers.
793 cr.dispatchSimpleEvent(this, 'scan-failed');
798 * Called when some chunk of entries are read by scanner.
800 * @param {boolean} refresh True to refresh metadata, or false to use cached
802 * @param {Array.<Entry>} entries The list of the scanned entries.
805 DirectoryContents.prototype.onNewEntries_ = function(refresh, entries) {
806 if (this.scanCancelled_)
809 var entriesFiltered = [].filter.call(
810 entries, this.context_.fileFilter.filter.bind(this.context_.fileFilter));
812 // Caching URL to reduce a number of calls of toURL in sort.
813 // This is a temporary solution. We need to fix a root cause of slow toURL.
814 // See crbug.com/370908 for detail.
815 entriesFiltered.forEach(function(entry) { entry.cachedUrl = entry.toURL(); });
817 if (entriesFiltered.length === 0)
820 // Enlarge the cache size into the new filelist size.
821 var newListSize = this.fileList_.length + entriesFiltered.length;
822 this.makeSpaceInMetadataCache_(newListSize);
824 this.processNewEntriesQueue_.run(function(callbackOuter) {
825 var finish = function() {
826 if (!this.scanCancelled_) {
827 // Just before inserting entries into the file list, check and avoid
829 var currentURLs = {};
830 for (var i = 0; i < this.fileList_.length; i++)
831 currentURLs[this.fileList_.item(i).toURL()] = true;
832 entriesFiltered = entriesFiltered.filter(function(entry) {
833 return !currentURLs[entry.toURL()];
835 // Update the filelist without waiting the metadata.
836 this.fileList_.push.apply(this.fileList_, entriesFiltered);
837 cr.dispatchSimpleEvent(this, 'scan-updated');
841 // Because the prefetchMetadata can be slow, throttling by splitting entries
842 // into smaller chunks to reduce UI latency.
843 // TODO(hidehiko,mtomasz): This should be handled in MetadataCache.
844 var MAX_CHUNK_SIZE = 25;
845 var prefetchMetadataQueue = new AsyncUtil.ConcurrentQueue(4);
846 for (var i = 0; i < entriesFiltered.length; i += MAX_CHUNK_SIZE) {
847 if (prefetchMetadataQueue.isCancelled())
850 var chunk = entriesFiltered.slice(i, i + MAX_CHUNK_SIZE);
851 prefetchMetadataQueue.run(function(chunk, callbackInner) {
852 this.prefetchMetadata(chunk, refresh, function() {
853 if (!prefetchMetadataQueue.isCancelled()) {
854 if (this.scanCancelled_)
855 prefetchMetadataQueue.cancel();
858 // Checks if this is the last task.
859 if (prefetchMetadataQueue.getWaitingTasksCount() === 0 &&
860 prefetchMetadataQueue.getRunningTasksCount() === 1) {
861 // |callbackOuter| in |finish| must be called before
862 // |callbackInner|, to prevent double-calling.
868 }.bind(this, chunk));
874 * @param {Array.<Entry>} entries Files.
875 * @param {boolean} refresh True to refresh metadata, or false to use cached
877 * @param {function(Object)} callback Callback on done.
879 DirectoryContents.prototype.prefetchMetadata =
880 function(entries, refresh, callback) {
881 var TYPES = 'filesystem|external';
883 this.context_.metadataCache.getLatest(entries, TYPES, callback);
885 this.context_.metadataCache.get(entries, TYPES, callback);
889 * Creates a DirectoryContents instance to show entries in a directory.
891 * @param {FileListContext} context File list context.
892 * @param {DirectoryEntry} directoryEntry The current directory entry.
893 * @return {DirectoryContents} Created DirectoryContents instance.
895 DirectoryContents.createForDirectory = function(context, directoryEntry) {
896 return new DirectoryContents(
898 false, // Non search.
901 return new DirectoryContentScanner(directoryEntry);
906 * Creates a DirectoryContents instance to show the result of the search on
909 * @param {FileListContext} context File list context.
910 * @param {DirectoryEntry} directoryEntry The current directory entry.
911 * @param {string} query Search query.
912 * @return {DirectoryContents} Created DirectoryContents instance.
914 DirectoryContents.createForDriveSearch = function(
915 context, directoryEntry, query) {
916 return new DirectoryContents(
921 return new DriveSearchContentScanner(query);
926 * Creates a DirectoryContents instance to show the result of the search on
929 * @param {FileListContext} context File list context.
930 * @param {DirectoryEntry} directoryEntry The current directory entry.
931 * @param {string} query Search query.
932 * @return {DirectoryContents} Created DirectoryContents instance.
934 DirectoryContents.createForLocalSearch = function(
935 context, directoryEntry, query) {
936 return new DirectoryContents(
941 return new LocalSearchContentScanner(directoryEntry, query);
946 * Creates a DirectoryContents instance to show the result of metadata search
947 * on Drive File System.
949 * @param {FileListContext} context File list context.
950 * @param {DirectoryEntry} fakeDirectoryEntry Fake directory entry representing
951 * the set of result entries. This serves as a top directory for the
953 * @param {!DriveMetadataSearchContentScanner.SearchType} searchType The type of
954 * the search. The scanner will restricts the entries based on the given
956 * @return {DirectoryContents} Created DirectoryContents instance.
958 DirectoryContents.createForDriveMetadataSearch = function(
959 context, fakeDirectoryEntry, searchType) {
960 return new DirectoryContents(
965 return new DriveMetadataSearchContentScanner(searchType);