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

Unified Diff: third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js

Issue 2016943004: DevTools: eliminate race condition in WI.StylesSourceMapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js b/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
index 64296ff8ac314a4bca495a06633d3c87e85d6b1a..d02ce0a5f8de7668078bb081ce7cd6fe1b16fb33 100644
--- a/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
@@ -331,10 +331,13 @@ WebInspector.StyleFile = function(uiSourceCode, mapping)
{
this._uiSourceCode = uiSourceCode;
this._mapping = mapping;
- this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
- this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
+ this._eventListeners = [
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this),
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this)
+ ];
this._uiSourceCode.forceLoadOnCheckContent();
this._commitThrottler = new WebInspector.Throttler(WebInspector.StyleFile.updateTimeout);
+ this._terminated = false;
}
WebInspector.StyleFile.updateTimeout = 200;
@@ -365,6 +368,8 @@ WebInspector.StyleFile.prototype = {
_commitIncrementalEdit: function()
{
+ if (this._terminated)
+ return;
var promise = this._mapping._setStyleContent(this._uiSourceCode, this._uiSourceCode.workingCopy(), this._isMajorChangePending)
.then(this._styleContentSet.bind(this))
this._isMajorChangePending = false;
@@ -392,7 +397,9 @@ WebInspector.StyleFile.prototype = {
dispose: function()
{
- this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
- this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
+ if (this._terminated)
+ return;
+ this._terminated = true;
+ WebInspector.EventTarget.removeEventListeners(this._eventListeners);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698