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

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

Issue 2585393003: DevTools: [Persistence] implement Persistence.subscribeForBindingEvents (Closed)
Patch Set: address comments Created 4 years 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 | third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8ecf83d5bcbaa8e205c2249b067f278813c19941..f2594adfbfdd5f6289d777c76ad87acd6f941043 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,9 @@ Persistence.Persistence = class extends Common.Object {
/** @type {!Map<string, number>} */
this._filePathPrefixesToBindingCount = new Map();
+ /** @type {!Multimap<!Workspace.UISourceCode, function()>} */
+ this._subscribedBindingEventListeners = new Multimap();
+
if (Runtime.experiments.isEnabled('persistence2')) {
var linkDecorator = new Persistence.PersistenceUtils.LinkDecorator(this);
Components.Linkifier.setLinkDecorator(linkDecorator);
@@ -94,6 +97,9 @@ Persistence.Persistence = class extends Common.Object {
this._addFilePathBindingPrefixes(binding.fileSystem.url());
this._moveBreakpoints(binding.fileSystem, binding.network);
+
+ this._notifyBindingEvent(binding.network);
+ this._notifyBindingEvent(binding.fileSystem);
this.dispatchEventToListeners(Persistence.Persistence.Events.BindingCreated, binding);
}
@@ -121,8 +127,10 @@ Persistence.Persistence = class extends Common.Object {
Workspace.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyChanged, this);
this._removeFilePathBindingPrefixes(binding.fileSystem.url());
-
this._breakpointManager.copyBreakpoints(binding.network.url(), binding.fileSystem);
+
+ this._notifyBindingEvent(binding.network);
+ this._notifyBindingEvent(binding.fileSystem);
this.dispatchEventToListeners(Persistence.Persistence.Events.BindingRemoved, binding);
}
@@ -268,6 +276,33 @@ Persistence.Persistence = class extends Common.Object {
/**
* @param {!Workspace.UISourceCode} uiSourceCode
+ * @param {function()} listener
+ */
+ subscribeForBindingEvent(uiSourceCode, listener) {
+ this._subscribedBindingEventListeners.set(uiSourceCode, listener);
+ }
+
+ /**
+ * @param {!Workspace.UISourceCode} uiSourceCode
+ * @param {function()} listener
+ */
+ unsubscribeFromBindingEvent(uiSourceCode, listener) {
+ this._subscribedBindingEventListeners.remove(uiSourceCode, listener);
+ }
+
+ /**
+ * @param {!Workspace.UISourceCode} uiSourceCode
+ */
+ _notifyBindingEvent(uiSourceCode) {
+ if (!this._subscribedBindingEventListeners.has(uiSourceCode))
+ return;
+ var listeners = Array.from(this._subscribedBindingEventListeners.get(uiSourceCode));
+ for (var listener of listeners)
+ listener.call(null);
+ }
+
+ /**
+ * @param {!Workspace.UISourceCode} uiSourceCode
* @return {?Workspace.UISourceCode}
*/
fileSystem(uiSourceCode) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698