Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1101)

Unified Diff: Source/devtools/front_end/UISourceCode.js

Issue 216183003: DevTools: Make sure UISC content is up-to-date when running performSearchInContent() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Introduce callback array for pending requests Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/SourcesSearchScope.js ('k') | Source/devtools/front_end/utilities.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
},
« no previous file with comments | « Source/devtools/front_end/SourcesSearchScope.js ('k') | Source/devtools/front_end/utilities.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698