Commit 1eeaf562 authored by Kinuko Yasuda's avatar Kinuko Yasuda Committed by Commit Bot

Revert "ES6 styles to onVolumeInfoListUpdated_ and setupCurrentDirectory_"

This reverts commit 0ad9fe79.

Reason for revert: speculative revert, will revert the revert if not a root cause.

Bunch of Video/file-manager related tests started to fail:
OpenVideoFiles/FilesAppBrowserTest.Test/videoOpenDrive_DriveFs
OpenVideoFiles/FilesAppBrowserTest.Test/videoOpenDownloads
VideoPlayerBrowserTest.OpenSingleVideoOnDrive
VideoPlayerBrowserTest.OpenSingleVideoOnDownloads
VideoPlayerBrowserTest.ClickControlButtons
OpenVideoFiles/FilesAppBrowserTest.Test/videoOpenDownloads_GuestMode
VideoPlayerBrowserTestInGuestMode.OpenSingleVideoOnDownloads
VideoPlayerBrowserTest.CheckInitialElements
OpenVideoFiles/FilesAppBrowserTest.Test/videoOpenDrive

Failures:
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Linux%20ChromiumOS%20MSan%20Tests/9115
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Linux%20ChromiumOS%20MSan%20Tests/9116

Original change's description:
> ES6 styles to onVolumeInfoListUpdated_ and setupCurrentDirectory_
> 
> Appliy ES6 features to the DirectoryModel.onVolumeInfoListUpdated_ and
> FileManager.setupCurrentDirectory_.
> 
> ES6 styles:
> - Change var to const or let.
> - Change anonymous functions+bind(this) to arrow functions.
> 
> Remove a TODO that linked to a closed bug.
> 
> Move comment to be before queue.run() to match the style of the
> previous lines.
> 
> Apply the formatting from git cl format, which is slightly uglier, but
> at least automatic. :-)
> 
> Test: No change in behaviour.
> Change-Id: I5564263d44f8639d97fc86d7add5a59e8938be6d
> Reviewed-on: https://chromium-review.googlesource.com/c/1286239
> Reviewed-by: Joel Hockey <joelhockey@chromium.org>
> Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#600312}

TBR=joelhockey@chromium.org,lucmult@chromium.org

Change-Id: I5f4aa388d2b88c5914c705c71b0fcc70904a42fe
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/1288169Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600640}
parent 2d9a7fc8
......@@ -1199,17 +1199,17 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) {
// When the volume where we are is unmounted, fallback to the default volume's
// root. If current directory path is empty, stop the fallback
// since the current directory is initializing now.
const entry = this.getCurrentDirEntry();
var entry = this.getCurrentDirEntry();
if (entry && !this.volumeManager_.getVolumeInfo(entry)) {
this.volumeManager_.getDefaultDisplayRoot((displayRoot) => {
this.volumeManager_.getDefaultDisplayRoot(function(displayRoot) {
if (displayRoot)
this.changeDirectoryEntry(displayRoot);
});
}.bind(this));
}
// If a new file backed provided volume is mounted,
// then redirect to it in the focused window.
// If crostini is mounted, redirect even if window is not focused.
// If crostini is mounted, redirect even if window is not focussed.
// Note, that this is a temporary solution for https://crbug.com/427776.
if (event.added.length !== 1)
return;
......@@ -1217,11 +1217,11 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) {
event.added[0].volumeType === VolumeManagerCommon.VolumeType.PROVIDED &&
event.added[0].source === VolumeManagerCommon.Source.FILE) ||
event.added[0].volumeType === VolumeManagerCommon.VolumeType.CROSTINI) {
event.added[0].resolveDisplayRoot().then((displayRoot) => {
event.added[0].resolveDisplayRoot().then(function(displayRoot) {
// Resolving a display root on FSP volumes is instant, despite the
// asynchronous call.
this.changeDirectoryEntry(event.added[0].displayRoot);
});
}.bind(this));
}
};
......
......@@ -1255,29 +1255,30 @@ FileManager.prototype = /** @struct */ {
* @private
*/
FileManager.prototype.setupCurrentDirectory_ = function() {
const tracker = this.directoryModel_.createDirectoryChangeTracker();
const queue = new AsyncUtil.Queue();
var tracker = this.directoryModel_.createDirectoryChangeTracker();
var queue = new AsyncUtil.Queue();
// Wait until the volume manager is initialized.
queue.run((callback) => {
queue.run(function(callback) {
tracker.start();
this.volumeManager_.ensureInitialized(callback);
});
}.bind(this));
let nextCurrentDirEntry;
let selectionEntry;
var nextCurrentDirEntry;
var selectionEntry;
// Resolve the selectionURL to selectionEntry or to currentDirectoryEntry
// in case of being a display root or a default directory to open files.
queue.run((callback) => {
queue.run(function(callback) {
if (!this.launchParams_.selectionURL) {
callback();
return;
}
window.webkitResolveLocalFileSystemURL(
this.launchParams_.selectionURL, (inEntry) => {
const locationInfo = this.volumeManager_.getLocationInfo(inEntry);
this.launchParams_.selectionURL,
function(inEntry) {
var locationInfo = this.volumeManager_.getLocationInfo(inEntry);
// If location information is not available, then the volume is
// no longer (or never) available.
if (!locationInfo) {
......@@ -1303,50 +1304,53 @@ FileManager.prototype = /** @struct */ {
selectionEntry = inEntry;
callback();
}, callback);
});
}.bind(this), callback);
}.bind(this));
// Resolve the currentDirectoryURL to currentDirectoryEntry (if not done
// by the previous step).
queue.run((callback) => {
queue.run(function(callback) {
if (nextCurrentDirEntry || !this.launchParams_.currentDirectoryURL) {
callback();
return;
}
window.webkitResolveLocalFileSystemURL(
this.launchParams_.currentDirectoryURL, (inEntry) => {
const locationInfo = this.volumeManager_.getLocationInfo(inEntry);
this.launchParams_.currentDirectoryURL,
function(inEntry) {
var locationInfo = this.volumeManager_.getLocationInfo(inEntry);
if (!locationInfo) {
callback();
return;
}
nextCurrentDirEntry = inEntry;
callback();
}, callback);
});
}.bind(this), callback);
// TODO(mtomasz): Implement reopening on special search, when fake
// entries are converted to directory providers. crbug.com/433161.
}.bind(this));
// If the directory to be changed to is not available, then first fallback
// to the parent of the selection entry.
queue.run((callback) => {
queue.run(function(callback) {
if (nextCurrentDirEntry || !selectionEntry) {
callback();
return;
}
selectionEntry.getParent((inEntry) => {
selectionEntry.getParent(function(inEntry) {
nextCurrentDirEntry = inEntry;
callback();
});
});
}.bind(this));
}.bind(this));
// Check if the next current directory is not a virtual directory which is
// not available in UI. This may happen to shared on Drive.
queue.run((callback) => {
queue.run(function(callback) {
if (!nextCurrentDirEntry) {
callback();
return;
}
const locationInfo =
this.volumeManager_.getLocationInfo(nextCurrentDirEntry);
var locationInfo = this.volumeManager_.getLocationInfo(
nextCurrentDirEntry);
// If we can't check, assume that the directory is illegal.
if (!locationInfo) {
nextCurrentDirEntry = null;
......@@ -1355,21 +1359,19 @@ FileManager.prototype = /** @struct */ {
}
// Having root directory of DRIVE_OTHER here should be only for shared
// with me files. Fallback to Drive root in such case.
if (locationInfo.isRootEntry &&
locationInfo.rootType === VolumeManagerCommon.RootType.DRIVE_OTHER) {
const volumeInfo =
this.volumeManager_.getVolumeInfo(nextCurrentDirEntry);
if (locationInfo.isRootEntry && locationInfo.rootType ===
VolumeManagerCommon.RootType.DRIVE_OTHER) {
var volumeInfo = this.volumeManager_.getVolumeInfo(nextCurrentDirEntry);
if (!volumeInfo) {
nextCurrentDirEntry = null;
callback();
return;
}
volumeInfo.resolveDisplayRoot()
.then((entry) => {
volumeInfo.resolveDisplayRoot().then(
function(entry) {
nextCurrentDirEntry = entry;
callback();
})
.catch((error) => {
}).catch(function(error) {
console.error(error.stack || error);
nextCurrentDirEntry = null;
callback();
......@@ -1377,25 +1379,25 @@ FileManager.prototype = /** @struct */ {
} else {
callback();
}
});
}.bind(this));
// If the directory to be changed to is still not resolved, then fallback
// to the default display root.
queue.run((callback) => {
queue.run(function(callback) {
if (nextCurrentDirEntry) {
callback();
return;
}
this.volumeManager_.getDefaultDisplayRoot((displayRoot) => {
this.volumeManager_.getDefaultDisplayRoot(function(displayRoot) {
nextCurrentDirEntry = displayRoot;
callback();
});
});
}.bind(this));
}.bind(this));
// If selection failed to be resolved (eg. didn't exist, in case of saving
// a file, or in case of a fallback of the current directory, then try to
// resolve again using the target name.
queue.run((callback) => {
queue.run(function(callback) {
if (selectionEntry ||
!nextCurrentDirEntry ||
!this.launchParams_.targetName) {
......@@ -1404,28 +1406,28 @@ FileManager.prototype = /** @struct */ {
}
// Try to resolve as a file first. If it fails, then as a directory.
nextCurrentDirEntry.getFile(
this.launchParams_.targetName, {},
(targetEntry) => {
this.launchParams_.targetName,
{},
function(targetEntry) {
selectionEntry = targetEntry;
callback();
},
() => {
}, function() {
// Failed to resolve as a file
nextCurrentDirEntry.getDirectory(
this.launchParams_.targetName, {},
(targetEntry) => {
this.launchParams_.targetName,
{},
function(targetEntry) {
selectionEntry = targetEntry;
callback();
},
() => {
}, function() {
// Failed to resolve as either file or directory.
callback();
});
});
});
}.bind(this));
}.bind(this));
// If there is no target select MyFiles by default.
queue.run((callback) => {
// If there is no target select MyFiles by default.
if (!nextCurrentDirEntry)
nextCurrentDirEntry = this.directoryTree.dataModel.myFilesModel_.entry;
......@@ -1433,7 +1435,7 @@ FileManager.prototype = /** @struct */ {
});
// Finalize.
queue.run((callback) => {
queue.run(function(callback) {
// Check directory change.
tracker.stop();
if (tracker.hasChanged) {
......@@ -1446,7 +1448,7 @@ FileManager.prototype = /** @struct */ {
selectionEntry,
this.launchParams_.targetName);
callback();
});
}.bind(this));
};
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment