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

Unified Diff: third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js

Issue 2925023003: DevTools: Avoid a race in WorkspaceDiff when UISourceCodes are removed (Closed)
Patch Set: done Created 3 years, 6 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/workspace_diff/WorkspaceDiff.js
diff --git a/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js b/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js
index dcda6053a0a53d24ccfcc00723d5285b0aec96bf..3d40fd14e8ebd4cfa71bcaf4277db1d14a2cb9af 100644
--- a/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js
+++ b/third_party/WebKit/Source/devtools/front_end/workspace_diff/WorkspaceDiff.js
@@ -89,8 +89,7 @@ WorkspaceDiff.WorkspaceDiff = class extends Common.Object {
*/
_uiSourceCodeRemoved(event) {
var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
- this._loadingUISourceCodes.delete(uiSourceCode);
- this._markAsUnmodified(uiSourceCode);
+ this._removeUISourceCode(uiSourceCode);
}
/**
@@ -98,10 +97,19 @@ WorkspaceDiff.WorkspaceDiff = class extends Common.Object {
*/
_projectRemoved(event) {
var project = /** @type {!Workspace.Project} */ (event.data);
- for (var uiSourceCode of project.uiSourceCodes()) {
- this._loadingUISourceCodes.delete(uiSourceCode);
- this._markAsUnmodified(uiSourceCode);
- }
+ for (var uiSourceCode of project.uiSourceCodes())
+ this._removeUISourceCode(uiSourceCode);
+ }
+
+ /**
+ * @param {!Workspace.UISourceCode} uiSourceCode
+ */
+ _removeUISourceCode(uiSourceCode) {
+ this._loadingUISourceCodes.delete(uiSourceCode);
+ var uiSourceCodeDiff = this._uiSourceCodeDiffs.get(uiSourceCode);
+ if (uiSourceCodeDiff)
+ uiSourceCodeDiff._dispose = true;
+ this._markAsUnmodified(uiSourceCode);
}
/**
@@ -171,6 +179,7 @@ WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff = class extends Common.Object {
uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeChanged, this);
this._requestDiffPromise = null;
this._pendingChanges = null;
+ this._dispose = false;
}
_uiSourceCodeChanged() {
@@ -188,6 +197,8 @@ WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff = class extends Common.Object {
* @this {WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff}
*/
function emitDiffChanged() {
+ if (this._dispose)
+ return;
this.dispatchEventToListeners(WorkspaceDiff.Events.DiffChanged);
this._pendingChanges = null;
}
@@ -206,10 +217,21 @@ WorkspaceDiff.WorkspaceDiff.UISourceCodeDiff = class extends Common.Object {
* @return {!Promise<?Diff.Diff.DiffArray>}
*/
async _innerRequestDiff() {
+ if (this._dispose)
+ return null;
+
var current = this._uiSourceCode.workingCopy();
if (!current && !this._uiSourceCode.contentLoaded())
current = await this._uiSourceCode.requestContent();
+ // ------------ ASYNC ------------
+ if (this._dispose)
+ return null;
+
var baseline = await this._uiSourceCode.requestOriginalContent();
+ // ------------ ASYNC ------------
+ if (this._dispose)
+ return null;
+
if (current === null || baseline === null)
return null;
return Diff.Diff.lineDiff(baseline.split('\n'), current.split('\n'));
« 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