Index: Source/devtools/front_end/UISourceCode.js |
diff --git a/Source/devtools/front_end/UISourceCode.js b/Source/devtools/front_end/UISourceCode.js |
index cf07f0b58f762dd85a315565698ee9922fe0bdbd..39c8d70892e9cacaa8b5bc2f169f7dbc524fce55 100644 |
--- a/Source/devtools/front_end/UISourceCode.js |
+++ b/Source/devtools/front_end/UISourceCode.js |
@@ -262,14 +262,39 @@ WebInspector.UISourceCode.prototype = { |
}, |
/** |
+ * @param {function()} callback |
+ */ |
+ _pushCheckContentUpdatedCallback: function(callback) |
+ { |
+ if (!this._checkContentUpdatedCallbacks) |
+ this._checkContentUpdatedCallbacks = []; |
+ this._checkContentUpdatedCallbacks.push(callback); |
+ }, |
+ |
+ _terminateContentCheck: function() |
+ { |
+ delete this._checkingContent; |
+ if (this._checkContentUpdatedCallbacks) { |
+ this._checkContentUpdatedCallbacks.forEach(function(callback) { callback(); }); |
+ delete this._checkContentUpdatedCallbacks; |
+ } |
+ }, |
+ |
+ /** |
* @param {function()=} callback |
*/ |
checkContentUpdated: function(callback) |
{ |
- if (!this._project.canSetFileContent()) |
+ callback = callback || function() {}; |
+ if (!this._project.canSetFileContent()) { |
+ callback(); |
return; |
- if (this._checkingContent) |
+ } |
+ this._pushCheckContentUpdatedCallback(callback); |
+ |
+ if (this._checkingContent) { |
return; |
+ } |
this._checkingContent = true; |
this._project.requestFileContent(this, contentLoaded.bind(this)); |
@@ -283,30 +308,22 @@ WebInspector.UISourceCode.prototype = { |
var workingCopy = this.workingCopy(); |
this._commitContent("", false); |
this.setWorkingCopy(workingCopy); |
- delete this._checkingContent; |
- if (callback) |
- callback(); |
+ this._terminateContentCheck(); |
return; |
} |
if (typeof this._lastAcceptedContent === "string" && this._lastAcceptedContent === updatedContent) { |
- delete this._checkingContent; |
- if (callback) |
- callback(); |
+ this._terminateContentCheck(); |
return; |
} |
if (this._content === updatedContent) { |
delete this._lastAcceptedContent; |
- delete this._checkingContent; |
- if (callback) |
- callback(); |
+ this._terminateContentCheck(); |
return; |
} |
if (!this.isDirty()) { |
this._commitContent(updatedContent, false); |
- delete this._checkingContent; |
- if (callback) |
- callback(); |
+ this._terminateContentCheck(); |
return; |
} |
@@ -315,9 +332,7 @@ WebInspector.UISourceCode.prototype = { |
this._commitContent(updatedContent, false); |
else |
this._lastAcceptedContent = updatedContent; |
- delete this._checkingContent; |
- if (callback) |
- callback(); |
+ this._terminateContentCheck(); |
} |
}, |