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

Unified Diff: third_party/WebKit/Source/devtools/front_end/persistence/Persistence.js

Issue 2369173002: DevTools: [Workspace] show network files in navigator (Closed)
Patch Set: address comments + improvement Created 4 years, 3 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
Index: third_party/WebKit/Source/devtools/front_end/persistence/Persistence.js
diff --git a/third_party/WebKit/Source/devtools/front_end/persistence/Persistence.js b/third_party/WebKit/Source/devtools/front_end/persistence/Persistence.js
index 1f6948e88fe8a3567490464212f07cb63dcbc31c..7235e4cc14e9af450cec257bdb42f8c72b377113 100644
--- a/third_party/WebKit/Source/devtools/front_end/persistence/Persistence.js
+++ b/third_party/WebKit/Source/devtools/front_end/persistence/Persistence.js
@@ -17,6 +17,10 @@ WebInspector.Persistence = function(workspace, breakpointManager, fileSystemMapp
this._fileSystemMapping = fileSystemMapping;
/** @type {!Set<!WebInspector.PersistenceBinding>} */
this._bindings = new Set();
+
+ /** @type {!Map<string, number>} */
+ this._filePathPrefixesToBindingCount = new Map();
+
this._eventListeners = [
workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._onUISourceCodeAdded, this),
workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved, this._onUISourceCodeRemoved, this),
@@ -123,6 +127,8 @@ WebInspector.Persistence.prototype = {
binding.fileSystem.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyCommitted, this);
binding.fileSystem.addEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._onFileSystemUISourceCodeRenamed, this);
+ this._addFilePathBindingPrefixes(binding.fileSystem.url());
+
this._moveBreakpoints(binding.fileSystem, binding.network);
this.dispatchEventToListeners(WebInspector.Persistence.Events.BindingCreated, binding);
},
@@ -143,6 +149,8 @@ WebInspector.Persistence.prototype = {
binding.fileSystem.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyCommitted, this);
binding.fileSystem.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._onFileSystemUISourceCodeRenamed, this);
+ this._removeFilePathBindingPrefixes(binding.fileSystem.url());
+
this._copyBreakpoints(binding.network, binding.fileSystem);
this.dispatchEventToListeners(WebInspector.Persistence.Events.BindingRemoved, binding);
},
@@ -256,6 +264,46 @@ WebInspector.Persistence.prototype = {
return uiSourceCode[WebInspector.Persistence._binding] || null;
},
+ /**
+ * @param {string} filePath
+ */
+ _addFilePathBindingPrefixes: function(filePath)
+ {
+ var relative = "";
+ for (var token of filePath.split("/")) {
+ relative += token + "/";
+ var count = this._filePathPrefixesToBindingCount.get(relative) || 0;
+ this._filePathPrefixesToBindingCount.set(relative, count + 1);
+ }
+ },
+
+ /**
+ * @param {string} filePath
+ */
+ _removeFilePathBindingPrefixes: function(filePath)
+ {
+ var relative = "";
+ for (var token of filePath.split("/")) {
+ relative += token + "/";
+ var count = this._filePathPrefixesToBindingCount.get(relative);
+ if (count === 1)
+ this._filePathPrefixesToBindingCount.delete(relative);
+ else
+ this._filePathPrefixesToBindingCount.set(relative, count - 1);
+ }
+ },
+
+ /**
+ * @param {string} filePath
+ * @return {boolean}
+ */
+ filePathHasBindings: function(filePath)
+ {
+ if (!filePath.endsWith("/"))
+ filePath += "/";
+ return this._filePathPrefixesToBindingCount.has(filePath);
+ },
+
dispose: function()
{
WebInspector.EventTarget.removeEventListeners(this._eventListeners);

Powered by Google App Engine
This is Rietveld 408576698