Commit c496054d authored by pfeldman's avatar pfeldman Committed by Commit bot

DevTools: remove unnecessary asynchrony from isolated filesystem.

BUG=529471

Review URL: https://codereview.chromium.org/1365443004

Cr-Commit-Position: refs/heads/master@{#351162}
parent cbf10aec
......@@ -39,8 +39,7 @@ WebInspector.IsolatedFileSystem = function(manager, path, name, rootURL)
{
this._manager = manager;
this._path = path;
this._name = name;
this._rootURL = rootURL;
this._domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL);
}
/**
......@@ -83,30 +82,6 @@ WebInspector.IsolatedFileSystem.prototype = {
return this._normalizedPath;
},
/**
* @return {string}
*/
name: function()
{
return this._name;
},
/**
* @return {string}
*/
rootURL: function()
{
return this._rootURL;
},
/**
* @param {function(?DOMFileSystem)} callback
*/
_requestFileSystem: function(callback)
{
this._manager.requestDOMFileSystem(this._path, callback);
},
/**
* @param {string} path
* @param {function(string)} fileCallback
......@@ -114,20 +89,8 @@ WebInspector.IsolatedFileSystem.prototype = {
*/
requestFilesRecursive: function(path, fileCallback, finishedCallback)
{
var domFileSystem;
var pendingRequests = 0;
this._requestFileSystem(fileSystemLoaded.bind(this));
/**
* @param {?DOMFileSystem} fs
* @this {WebInspector.IsolatedFileSystem}
*/
function fileSystemLoaded(fs)
{
domFileSystem = /** @type {!DOMFileSystem} */ (fs);
console.assert(domFileSystem);
++pendingRequests;
this._requestEntries(domFileSystem, path, innerCallback.bind(this));
}
var pendingRequests = 1;
this._requestEntries(path, innerCallback.bind(this));
/**
* @param {!Array.<!FileEntry>} entries
......@@ -146,7 +109,7 @@ WebInspector.IsolatedFileSystem.prototype = {
if (this._manager.excludedFolderManager().isFileExcluded(this._path, entry.fullPath + "/"))
continue;
++pendingRequests;
this._requestEntries(domFileSystem, entry.fullPath, innerCallback.bind(this));
this._requestEntries(entry.fullPath, innerCallback.bind(this));
}
}
if (finishedCallback && (--pendingRequests === 0))
......@@ -161,22 +124,12 @@ WebInspector.IsolatedFileSystem.prototype = {
*/
createFile: function(path, name, callback)
{
this._requestFileSystem(fileSystemLoaded.bind(this));
var newFileIndex = 1;
if (!name)
name = "NewFile";
var nameCandidate;
/**
* @param {?DOMFileSystem} fs
* @this {WebInspector.IsolatedFileSystem}
*/
function fileSystemLoaded(fs)
{
var domFileSystem = /** @type {!DOMFileSystem} */ (fs);
console.assert(domFileSystem);
domFileSystem.root.getDirectory(path, null, dirEntryLoaded.bind(this), errorHandler.bind(this));
}
this._domFileSystem.root.getDirectory(path, null, dirEntryLoaded.bind(this), errorHandler.bind(this));
/**
* @param {!DirectoryEntry} dirEntry
......@@ -230,18 +183,7 @@ WebInspector.IsolatedFileSystem.prototype = {
*/
deleteFile: function(path)
{
this._requestFileSystem(fileSystemLoaded.bind(this));
/**
* @param {?DOMFileSystem} fs
* @this {WebInspector.IsolatedFileSystem}
*/
function fileSystemLoaded(fs)
{
var domFileSystem = /** @type {!DOMFileSystem} */ (fs);
console.assert(domFileSystem);
domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), errorHandler.bind(this));
}
this._domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), errorHandler.bind(this));
/**
* @param {!FileEntry} fileEntry
......@@ -273,17 +215,7 @@ WebInspector.IsolatedFileSystem.prototype = {
*/
requestMetadata: function(path, callback)
{
this._requestFileSystem(fileSystemLoaded);
/**
* @param {?DOMFileSystem} fs
*/
function fileSystemLoaded(fs)
{
var domFileSystem = /** @type {!DOMFileSystem} */ (fs);
console.assert(domFileSystem);
domFileSystem.root.getFile(path, null, fileEntryLoaded, errorHandler);
}
this._domFileSystem.root.getFile(path, null, fileEntryLoaded, errorHandler);
/**
* @param {!FileEntry} entry
......@@ -316,18 +248,7 @@ WebInspector.IsolatedFileSystem.prototype = {
*/
requestFileContent: function(path, callback)
{
this._requestFileSystem(fileSystemLoaded.bind(this));
/**
* @param {?DOMFileSystem} fs
* @this {WebInspector.IsolatedFileSystem}
*/
function fileSystemLoaded(fs)
{
var domFileSystem = /** @type {!DOMFileSystem} */ (fs);
console.assert(domFileSystem);
domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), errorHandler.bind(this));
}
this._domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), errorHandler.bind(this));
/**
* @param {!FileEntry} entry
......@@ -386,19 +307,8 @@ WebInspector.IsolatedFileSystem.prototype = {
*/
setFileContent: function(path, content, callback)
{
this._requestFileSystem(fileSystemLoaded.bind(this));
WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.FileSavedInWorkspace);
/**
* @param {?DOMFileSystem} fs
* @this {WebInspector.IsolatedFileSystem}
*/
function fileSystemLoaded(fs)
{
var domFileSystem = /** @type {!DOMFileSystem} */ (fs);
console.assert(domFileSystem);
domFileSystem.root.getFile(path, { create: true }, fileEntryLoaded.bind(this), errorHandler.bind(this));
}
this._domFileSystem.root.getFile(path, { create: true }, fileEntryLoaded.bind(this), errorHandler.bind(this));
/**
* @param {!FileEntry} entry
......@@ -452,18 +362,8 @@ WebInspector.IsolatedFileSystem.prototype = {
}
var fileEntry;
var dirEntry;
this._requestFileSystem(fileSystemLoaded.bind(this));
/**
* @param {?DOMFileSystem} fs
* @this {WebInspector.IsolatedFileSystem}
*/
function fileSystemLoaded(fs)
{
var domFileSystem = /** @type {!DOMFileSystem} */ (fs);
console.assert(domFileSystem);
domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), errorHandler.bind(this));
}
this._domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), errorHandler.bind(this));
/**
* @param {!FileEntry} entry
......@@ -564,13 +464,12 @@ WebInspector.IsolatedFileSystem.prototype = {
},
/**
* @param {!DOMFileSystem} domFileSystem
* @param {string} path
* @param {function(!Array.<!FileEntry>)} callback
*/
_requestEntries: function(domFileSystem, path, callback)
_requestEntries: function(path, callback)
{
domFileSystem.root.getDirectory(path, null, innerCallback.bind(this), errorHandler);
this._domFileSystem.root.getDirectory(path, null, innerCallback.bind(this), errorHandler);
/**
* @param {!DirectoryEntry} dirEntry
......
......@@ -36,8 +36,6 @@ WebInspector.IsolatedFileSystemManager = function()
{
/** @type {!Object.<string, !WebInspector.IsolatedFileSystem>} */
this._fileSystems = {};
/** @type {!Object.<string, !Array.<function(?DOMFileSystem)>>} */
this._pendingFileSystemRequests = {};
this._excludedFolderManager = new WebInspector.ExcludedFolderManager();
InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.FileSystemsLoaded, this._onFileSystemsLoaded, this);
......@@ -101,7 +99,6 @@ WebInspector.IsolatedFileSystemManager.prototype = {
this._initializeCallback();
delete this._initializeCallback;
this._processPendingFileSystemRequests();
},
/**
......@@ -115,16 +112,6 @@ WebInspector.IsolatedFileSystemManager.prototype = {
this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemAdded, isolatedFileSystem);
},
_processPendingFileSystemRequests: function()
{
for (var fileSystemPath in this._pendingFileSystemRequests) {
var callbacks = this._pendingFileSystemRequests[fileSystemPath];
for (var i = 0; i < callbacks.length; ++i)
callbacks[i](this._isolatedFileSystem(fileSystemPath));
}
delete this._pendingFileSystemRequests;
},
/**
* @param {!WebInspector.Event} event
*/
......@@ -158,35 +145,6 @@ WebInspector.IsolatedFileSystemManager.prototype = {
this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, isolatedFileSystem);
},
/**
* @param {string} fileSystemPath
* @return {?DOMFileSystem}
*/
_isolatedFileSystem: function(fileSystemPath)
{
var fileSystem = this._fileSystems[fileSystemPath];
if (!fileSystem)
return null;
if (!InspectorFrontendHost.isolatedFileSystem)
return null;
return InspectorFrontendHost.isolatedFileSystem(fileSystem.name(), fileSystem.rootURL());
},
/**
* @param {string} fileSystemPath
* @param {function(?DOMFileSystem)} callback
*/
requestDOMFileSystem: function(fileSystemPath, callback)
{
if (!this._loaded) {
if (!this._pendingFileSystemRequests[fileSystemPath])
this._pendingFileSystemRequests[fileSystemPath] = this._pendingFileSystemRequests[fileSystemPath] || [];
this._pendingFileSystemRequests[fileSystemPath].push(callback);
return;
}
callback(this._isolatedFileSystem(fileSystemPath));
},
/**
* @return {!Array<string>}
*/
......
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