| Index: ui/file_manager/file_manager/foreground/js/directory_model.js
|
| diff --git a/ui/file_manager/file_manager/foreground/js/directory_model.js b/ui/file_manager/file_manager/foreground/js/directory_model.js
|
| index b4b99013c149e01c8887c7a02cbaf60c102bdec1..4a8fe5f374141551f053a09c44542b17199b810f 100644
|
| --- a/ui/file_manager/file_manager/foreground/js/directory_model.js
|
| +++ b/ui/file_manager/file_manager/foreground/js/directory_model.js
|
| @@ -492,8 +492,8 @@ DirectoryModel.prototype.rescan = function(refresh) {
|
| * is completed successfully, false if the scan is failed.
|
| * @private
|
| */
|
| -DirectoryModel.prototype.clearAndScan_ = function(newDirContents,
|
| - callback) {
|
| +DirectoryModel.prototype.clearAndScan_ = function(newDirContents, callback) {
|
| + var previousDirectoryEntry = this.currentDirContents_.getDirectoryEntry();
|
| if (this.currentDirContents_.isScanning())
|
| this.currentDirContents_.cancelScan();
|
| this.currentDirContents_ = newDirContents;
|
| @@ -551,7 +551,14 @@ DirectoryModel.prototype.clearAndScan_ = function(newDirContents,
|
| }.bind(this);
|
|
|
| // Clear the table, and start scanning.
|
| - this.metadataModel_.clearAllCache();
|
| + if (previousDirectoryEntry &&
|
| + previousDirectoryEntry.toURL() ===
|
| + this.currentDirContents_.getDirectoryEntry().toURL()) {
|
| + console.log('same so skip metadata flush.');
|
| + } else {
|
| + console.log('not same so not skip metadata flush.');
|
| + this.metadataModel_.clearAllCache();
|
| + }
|
| cr.dispatchSimpleEvent(this, 'scan-started');
|
| var fileList = this.getFileList();
|
| fileList.splice(0, fileList.length);
|
| @@ -1185,11 +1192,15 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) {
|
| * @param {FileListContext} context File list context.
|
| * @param {!DirectoryEntry|!FakeEntry} entry Current directory.
|
| * @param {string=} opt_query Search query string.
|
| + * @param {CachedDirectoryReaderFactory=} opt_cachedReaderFactory
|
| * @return {DirectoryContents} Directory contents.
|
| * @private
|
| */
|
| -DirectoryModel.prototype.createDirectoryContents_ =
|
| - function(context, entry, opt_query) {
|
| +DirectoryModel.prototype.createDirectoryContents_ = function(
|
| + context, entry, opt_query, opt_cachedReaderFactory) {
|
| + if (!opt_cachedReaderFactory) {
|
| + console.log('creating with no cachedReaderFactory');
|
| + }
|
| var query = (opt_query || '').trimLeft();
|
| var locationInfo = this.volumeManager_.getLocationInfo(entry);
|
| if (!locationInfo)
|
| @@ -1205,8 +1216,10 @@ DirectoryModel.prototype.createDirectoryContents_ =
|
| } else if (query) {
|
| // Local search.
|
| return DirectoryContents.createForLocalSearch(
|
| - context, /** @type {!DirectoryEntry} */ (entry), query);
|
| - } if (locationInfo.isSpecialSearchRoot) {
|
| + context, /** @type {!DirectoryEntry} */ (entry), query,
|
| + opt_cachedReaderFactory);
|
| + }
|
| + if (locationInfo.isSpecialSearchRoot) {
|
| // Drive special search.
|
| var searchType;
|
| switch (locationInfo.rootType) {
|
| @@ -1233,7 +1246,8 @@ DirectoryModel.prototype.createDirectoryContents_ =
|
| } else {
|
| // Local fetch or search.
|
| return DirectoryContents.createForDirectory(
|
| - context, /** @type {!DirectoryEntry} */ (entry));
|
| + context, /** @type {!DirectoryEntry} */ (entry),
|
| + opt_cachedReaderFactory);
|
| }
|
| };
|
|
|
| @@ -1241,33 +1255,39 @@ DirectoryModel.prototype.createDirectoryContents_ =
|
| * Gets the last search query.
|
| * @return {string} the last search query.
|
| */
|
| -DirectoryModel.prototype.getLastSearchQuery = function() {
|
| +DirectoryModel.prototype.getLastSearchQuery =
|
| + function() {
|
| return this.lastSearchQuery_;
|
| }
|
|
|
| -/**
|
| - * Clears the last search query with the empty string.
|
| - */
|
| -DirectoryModel.prototype.clearLastSearchQuery = function() {
|
| + /**
|
| + * Clears the last search query with the empty string.
|
| + */
|
| + DirectoryModel.prototype.clearLastSearchQuery =
|
| + function() {
|
| this.lastSearchQuery_ = '';
|
| }
|
|
|
| -/**
|
| - * Performs search and displays results. The search type is dependent on the
|
| - * current directory. If we are currently on drive, server side content search
|
| - * over drive mount point. If the current directory is not on the drive, file
|
| - * name search over current directory will be performed.
|
| - *
|
| - * @param {string} query Query that will be searched for.
|
| - * @param {function(Event)} onSearchRescan Function that will be called when the
|
| - * search directory is rescanned (i.e. search results are displayed).
|
| - * @param {function()} onClearSearch Function to be called when search state
|
| - * gets cleared.
|
| - * TODO(olege): Change callbacks to events.
|
| - */
|
| -DirectoryModel.prototype.search = function(query,
|
| - onSearchRescan,
|
| - onClearSearch) {
|
| + /**
|
| + * Performs search and displays results. The search type is dependent on
|
| + * the current directory. If we are currently on drive, server side
|
| + * content search over drive mount point. If the current directory is
|
| + * not on the drive, file name search over current directory will be
|
| + * performed.
|
| + *
|
| + * @param {string} query Query that will be searched for.
|
| + * @param {function(Event)} onSearchRescan Function that will be called
|
| + * when the search directory is rescanned (i.e. search results are
|
| + * displayed).
|
| + * @param {function()} onClearSearch Function to be called when search
|
| + * state gets cleared.
|
| + * TODO(olege): Change callbacks to events.
|
| + */
|
| + DirectoryModel.prototype.search = function(
|
| + query, onSearchRescan, onClearSearch) {
|
| + console.log('search start. query: "' + query + '"');
|
| + var currentCachedReader = this.currentDirContents_.getCachedReaderFactory();
|
| + var t1 = performance.now();
|
| this.lastSearchQuery_ = query;
|
| this.clearSearch_();
|
| var currentDirEntry = this.getCurrentDirEntry();
|
| @@ -1276,6 +1296,14 @@ DirectoryModel.prototype.search = function(query,
|
| return;
|
| }
|
|
|
| + if (currentCachedReader) {
|
| + console.log('has current cached reader');
|
| + } else {
|
| + console.log('does not have current cached reader');
|
| + }
|
| +
|
| + console.log(this.currentFileListContext_.fileList);
|
| +
|
| this.changeDirectorySequence_++;
|
| this.directoryChangeQueue_.run(function(sequence, callback) {
|
| if (this.changeDirectorySequence_ !== sequence) {
|
| @@ -1286,8 +1314,8 @@ DirectoryModel.prototype.search = function(query,
|
| if (!(query || '').trimLeft()) {
|
| if (this.isSearching()) {
|
| var newDirContents = this.createDirectoryContents_(
|
| - this.currentFileListContext_,
|
| - assert(currentDirEntry));
|
| + this.currentFileListContext_, assert(currentDirEntry), '',
|
| + currentCachedReader);
|
| this.clearAndScan_(newDirContents,
|
| callback);
|
| } else {
|
| @@ -1297,12 +1325,31 @@ DirectoryModel.prototype.search = function(query,
|
| }
|
|
|
| var newDirContents = this.createDirectoryContents_(
|
| - this.currentFileListContext_, assert(currentDirEntry), query);
|
| + this.currentFileListContext_, assert(currentDirEntry), query,
|
| + currentCachedReader);
|
| if (!newDirContents) {
|
| callback();
|
| return;
|
| }
|
|
|
| + var scanCompl = function() {
|
| + var t2 = performance.now();
|
| + console.log('search "' + query + '" completed. took ' + (t2 - t1));
|
| + this.removeEventListener('scan-completed', scanCompl);
|
| + this.removeEventListener('scan-cancelled', scanCompl);
|
| + }.bind(this);
|
| + this.addEventListener('scan-completed', scanCompl);
|
| + this.addEventListener('scan-cancelled', scanCompl);
|
| + var t3;
|
| + var scanUpd = function() {
|
| + if (!t3) {
|
| + t3 = performance.now();
|
| + console.log('search "' + query + '" first show. took ' + (t3 - t1));
|
| + }
|
| + this.removeEventListener('scan-updated', scanUpd);
|
| + }.bind(this);
|
| + this.addEventListener('scan-updated', scanUpd);
|
| +
|
| this.onSearchCompleted_ = onSearchRescan;
|
| this.onClearSearch_ = onClearSearch;
|
| this.addEventListener('scan-completed', this.onSearchCompleted_);
|
|
|