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) { ...@@ -1199,17 +1199,17 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) {
// When the volume where we are is unmounted, fallback to the default volume's // When the volume where we are is unmounted, fallback to the default volume's
// root. If current directory path is empty, stop the fallback // root. If current directory path is empty, stop the fallback
// since the current directory is initializing now. // since the current directory is initializing now.
const entry = this.getCurrentDirEntry(); var entry = this.getCurrentDirEntry();
if (entry && !this.volumeManager_.getVolumeInfo(entry)) { if (entry && !this.volumeManager_.getVolumeInfo(entry)) {
this.volumeManager_.getDefaultDisplayRoot((displayRoot) => { this.volumeManager_.getDefaultDisplayRoot(function(displayRoot) {
if (displayRoot) if (displayRoot)
this.changeDirectoryEntry(displayRoot); this.changeDirectoryEntry(displayRoot);
}); }.bind(this));
} }
// If a new file backed provided volume is mounted, // If a new file backed provided volume is mounted,
// then redirect to it in the focused window. // 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. // Note, that this is a temporary solution for https://crbug.com/427776.
if (event.added.length !== 1) if (event.added.length !== 1)
return; return;
...@@ -1217,11 +1217,11 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) { ...@@ -1217,11 +1217,11 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) {
event.added[0].volumeType === VolumeManagerCommon.VolumeType.PROVIDED && event.added[0].volumeType === VolumeManagerCommon.VolumeType.PROVIDED &&
event.added[0].source === VolumeManagerCommon.Source.FILE) || event.added[0].source === VolumeManagerCommon.Source.FILE) ||
event.added[0].volumeType === VolumeManagerCommon.VolumeType.CROSTINI) { 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 // Resolving a display root on FSP volumes is instant, despite the
// asynchronous call. // asynchronous call.
this.changeDirectoryEntry(event.added[0].displayRoot); this.changeDirectoryEntry(event.added[0].displayRoot);
}); }.bind(this));
} }
}; };
......
...@@ -1255,29 +1255,30 @@ FileManager.prototype = /** @struct */ { ...@@ -1255,29 +1255,30 @@ FileManager.prototype = /** @struct */ {
* @private * @private
*/ */
FileManager.prototype.setupCurrentDirectory_ = function() { FileManager.prototype.setupCurrentDirectory_ = function() {
const tracker = this.directoryModel_.createDirectoryChangeTracker(); var tracker = this.directoryModel_.createDirectoryChangeTracker();
const queue = new AsyncUtil.Queue(); var queue = new AsyncUtil.Queue();
// Wait until the volume manager is initialized. // Wait until the volume manager is initialized.
queue.run((callback) => { queue.run(function(callback) {
tracker.start(); tracker.start();
this.volumeManager_.ensureInitialized(callback); this.volumeManager_.ensureInitialized(callback);
}); }.bind(this));
let nextCurrentDirEntry; var nextCurrentDirEntry;
let selectionEntry; var selectionEntry;
// Resolve the selectionURL to selectionEntry or to currentDirectoryEntry // Resolve the selectionURL to selectionEntry or to currentDirectoryEntry
// in case of being a display root or a default directory to open files. // 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) { if (!this.launchParams_.selectionURL) {
callback(); callback();
return; return;
} }
window.webkitResolveLocalFileSystemURL( window.webkitResolveLocalFileSystemURL(
this.launchParams_.selectionURL, (inEntry) => { this.launchParams_.selectionURL,
const locationInfo = this.volumeManager_.getLocationInfo(inEntry); function(inEntry) {
var locationInfo = this.volumeManager_.getLocationInfo(inEntry);
// If location information is not available, then the volume is // If location information is not available, then the volume is
// no longer (or never) available. // no longer (or never) available.
if (!locationInfo) { if (!locationInfo) {
...@@ -1303,50 +1304,53 @@ FileManager.prototype = /** @struct */ { ...@@ -1303,50 +1304,53 @@ FileManager.prototype = /** @struct */ {
selectionEntry = inEntry; selectionEntry = inEntry;
callback(); callback();
}, callback); }.bind(this), callback);
}); }.bind(this));
// Resolve the currentDirectoryURL to currentDirectoryEntry (if not done // Resolve the currentDirectoryURL to currentDirectoryEntry (if not done
// by the previous step). // by the previous step).
queue.run((callback) => { queue.run(function(callback) {
if (nextCurrentDirEntry || !this.launchParams_.currentDirectoryURL) { if (nextCurrentDirEntry || !this.launchParams_.currentDirectoryURL) {
callback(); callback();
return; return;
} }
window.webkitResolveLocalFileSystemURL( window.webkitResolveLocalFileSystemURL(
this.launchParams_.currentDirectoryURL, (inEntry) => { this.launchParams_.currentDirectoryURL,
const locationInfo = this.volumeManager_.getLocationInfo(inEntry); function(inEntry) {
var locationInfo = this.volumeManager_.getLocationInfo(inEntry);
if (!locationInfo) { if (!locationInfo) {
callback(); callback();
return; return;
} }
nextCurrentDirEntry = inEntry; nextCurrentDirEntry = inEntry;
callback(); 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 // If the directory to be changed to is not available, then first fallback
// to the parent of the selection entry. // to the parent of the selection entry.
queue.run((callback) => { queue.run(function(callback) {
if (nextCurrentDirEntry || !selectionEntry) { if (nextCurrentDirEntry || !selectionEntry) {
callback(); callback();
return; return;
} }
selectionEntry.getParent((inEntry) => { selectionEntry.getParent(function(inEntry) {
nextCurrentDirEntry = inEntry; nextCurrentDirEntry = inEntry;
callback(); callback();
}); }.bind(this));
}); }.bind(this));
// Check if the next current directory is not a virtual directory which is // Check if the next current directory is not a virtual directory which is
// not available in UI. This may happen to shared on Drive. // not available in UI. This may happen to shared on Drive.
queue.run((callback) => { queue.run(function(callback) {
if (!nextCurrentDirEntry) { if (!nextCurrentDirEntry) {
callback(); callback();
return; return;
} }
const locationInfo = var locationInfo = this.volumeManager_.getLocationInfo(
this.volumeManager_.getLocationInfo(nextCurrentDirEntry); nextCurrentDirEntry);
// If we can't check, assume that the directory is illegal. // If we can't check, assume that the directory is illegal.
if (!locationInfo) { if (!locationInfo) {
nextCurrentDirEntry = null; nextCurrentDirEntry = null;
...@@ -1355,21 +1359,19 @@ FileManager.prototype = /** @struct */ { ...@@ -1355,21 +1359,19 @@ FileManager.prototype = /** @struct */ {
} }
// Having root directory of DRIVE_OTHER here should be only for shared // Having root directory of DRIVE_OTHER here should be only for shared
// with me files. Fallback to Drive root in such case. // with me files. Fallback to Drive root in such case.
if (locationInfo.isRootEntry && if (locationInfo.isRootEntry && locationInfo.rootType ===
locationInfo.rootType === VolumeManagerCommon.RootType.DRIVE_OTHER) { VolumeManagerCommon.RootType.DRIVE_OTHER) {
const volumeInfo = var volumeInfo = this.volumeManager_.getVolumeInfo(nextCurrentDirEntry);
this.volumeManager_.getVolumeInfo(nextCurrentDirEntry);
if (!volumeInfo) { if (!volumeInfo) {
nextCurrentDirEntry = null; nextCurrentDirEntry = null;
callback(); callback();
return; return;
} }
volumeInfo.resolveDisplayRoot() volumeInfo.resolveDisplayRoot().then(
.then((entry) => { function(entry) {
nextCurrentDirEntry = entry; nextCurrentDirEntry = entry;
callback(); callback();
}) }).catch(function(error) {
.catch((error) => {
console.error(error.stack || error); console.error(error.stack || error);
nextCurrentDirEntry = null; nextCurrentDirEntry = null;
callback(); callback();
...@@ -1377,25 +1379,25 @@ FileManager.prototype = /** @struct */ { ...@@ -1377,25 +1379,25 @@ FileManager.prototype = /** @struct */ {
} else { } else {
callback(); callback();
} }
}); }.bind(this));
// If the directory to be changed to is still not resolved, then fallback // If the directory to be changed to is still not resolved, then fallback
// to the default display root. // to the default display root.
queue.run((callback) => { queue.run(function(callback) {
if (nextCurrentDirEntry) { if (nextCurrentDirEntry) {
callback(); callback();
return; return;
} }
this.volumeManager_.getDefaultDisplayRoot((displayRoot) => { this.volumeManager_.getDefaultDisplayRoot(function(displayRoot) {
nextCurrentDirEntry = displayRoot; nextCurrentDirEntry = displayRoot;
callback(); callback();
}); }.bind(this));
}); }.bind(this));
// If selection failed to be resolved (eg. didn't exist, in case of saving // 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 // a file, or in case of a fallback of the current directory, then try to
// resolve again using the target name. // resolve again using the target name.
queue.run((callback) => { queue.run(function(callback) {
if (selectionEntry || if (selectionEntry ||
!nextCurrentDirEntry || !nextCurrentDirEntry ||
!this.launchParams_.targetName) { !this.launchParams_.targetName) {
...@@ -1404,28 +1406,28 @@ FileManager.prototype = /** @struct */ { ...@@ -1404,28 +1406,28 @@ FileManager.prototype = /** @struct */ {
} }
// Try to resolve as a file first. If it fails, then as a directory. // Try to resolve as a file first. If it fails, then as a directory.
nextCurrentDirEntry.getFile( nextCurrentDirEntry.getFile(
this.launchParams_.targetName, {}, this.launchParams_.targetName,
(targetEntry) => { {},
function(targetEntry) {
selectionEntry = targetEntry; selectionEntry = targetEntry;
callback(); callback();
}, }, function() {
() => {
// Failed to resolve as a file // Failed to resolve as a file
nextCurrentDirEntry.getDirectory( nextCurrentDirEntry.getDirectory(
this.launchParams_.targetName, {}, this.launchParams_.targetName,
(targetEntry) => { {},
function(targetEntry) {
selectionEntry = targetEntry; selectionEntry = targetEntry;
callback(); callback();
}, }, function() {
() => {
// Failed to resolve as either file or directory. // Failed to resolve as either file or directory.
callback(); callback();
}); });
}); }.bind(this));
}); }.bind(this));
// If there is no target select MyFiles by default.
queue.run((callback) => { queue.run((callback) => {
// If there is no target select MyFiles by default.
if (!nextCurrentDirEntry) if (!nextCurrentDirEntry)
nextCurrentDirEntry = this.directoryTree.dataModel.myFilesModel_.entry; nextCurrentDirEntry = this.directoryTree.dataModel.myFilesModel_.entry;
...@@ -1433,7 +1435,7 @@ FileManager.prototype = /** @struct */ { ...@@ -1433,7 +1435,7 @@ FileManager.prototype = /** @struct */ {
}); });
// Finalize. // Finalize.
queue.run((callback) => { queue.run(function(callback) {
// Check directory change. // Check directory change.
tracker.stop(); tracker.stop();
if (tracker.hasChanged) { if (tracker.hasChanged) {
...@@ -1446,7 +1448,7 @@ FileManager.prototype = /** @struct */ { ...@@ -1446,7 +1448,7 @@ FileManager.prototype = /** @struct */ {
selectionEntry, selectionEntry,
this.launchParams_.targetName); this.launchParams_.targetName);
callback(); 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