Index: third_party/WebKit/Source/devtools/front_end/persistence/FileSystemWorkspaceBinding.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/persistence/FileSystemWorkspaceBinding.js b/third_party/WebKit/Source/devtools/front_end/persistence/FileSystemWorkspaceBinding.js |
index 8091642bebe380935fc48ef7a856273015a9bb6b..607200b689b33c966bbf3b9fb283ccd1d06c3e2e 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/persistence/FileSystemWorkspaceBinding.js |
+++ b/third_party/WebKit/Source/devtools/front_end/persistence/FileSystemWorkspaceBinding.js |
@@ -196,6 +196,9 @@ Persistence.FileSystemWorkspaceBinding.FileSystem = class extends Workspace.Proj |
super(workspace, id, Workspace.projectTypes.FileSystem, displayName); |
+ /** @type {!WeakMap<!Workspace.UISourceCode, !Promise<?string>>} */ |
+ this._originalContent = new WeakMap(); |
+ |
this._fileSystem = isolatedFileSystem; |
this._fileSystemBaseURL = this._fileSystem.path() + '/'; |
this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; |
@@ -286,6 +289,21 @@ Persistence.FileSystemWorkspaceBinding.FileSystem = class extends Workspace.Proj |
/** |
* @override |
+ * @param {!Workspace.UISourceCode} uiSourceCode |
+ * @return {!Promise<?string>} |
+ */ |
+ requestOriginalFileContent(uiSourceCode) { |
+ if (this._originalContent.has(uiSourceCode)) |
+ return this._originalContent.get(uiSourceCode); |
+ var fulfill; |
+ var promise = new Promise(x => fulfill = x); |
+ this.requestFileContent(uiSourceCode, fulfill); |
+ this._originalContent.set(uiSourceCode, promise); |
+ return promise; |
+ } |
+ |
+ /** |
+ * @override |
* @return {boolean} |
*/ |
canSetFileContent() { |
@@ -296,11 +314,12 @@ Persistence.FileSystemWorkspaceBinding.FileSystem = class extends Workspace.Proj |
* @override |
* @param {!Workspace.UISourceCode} uiSourceCode |
* @param {string} newContent |
- * @param {function(?string)} callback |
einbinder
2016/12/20 03:10:34
The parameter in the callback was never used.
|
+ * @param {function()} callback |
*/ |
setFileContent(uiSourceCode, newContent, callback) { |
var filePath = this._filePathForUISourceCode(uiSourceCode); |
- this._fileSystem.setFileContent(filePath, newContent, callback.bind(this, '')); |
einbinder
2016/12/20 03:10:34
Bind the callback to this?! What is going on.
|
+ this.requestOriginalFileContent(uiSourceCode) |
+ .then(() => this._fileSystem.setFileContent(filePath, newContent, callback)); |
} |
/** |