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

Unified Diff: tools/turbolizer/selection-broker.js

Issue 729913004: Add a html-based visualizer for TurboFan graphs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback 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 | « tools/turbolizer/selection.js ('k') | tools/turbolizer/text-view.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/turbolizer/selection-broker.js
diff --git a/tools/turbolizer/selection-broker.js b/tools/turbolizer/selection-broker.js
new file mode 100644
index 0000000000000000000000000000000000000000..3a223d8b643097079d68b543eadc741e797c7977
--- /dev/null
+++ b/tools/turbolizer/selection-broker.js
@@ -0,0 +1,46 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var SelectionBroker = function() {
+ this.brokers = [];
+ this.dispatching = false;
+ this.lastDispatchingHandler = null;
+};
+
+SelectionBroker.prototype.addSelectionHandler = function(handler) {
+ this.brokers.push(handler);
+}
+
+SelectionBroker.prototype.select = function(from, ranges, selected) {
+ if (!this.dispatching) {
+ this.lastDispatchingHandler = from;
+ try {
+ this.dispatching = true;
+ for (var b of this.brokers) {
+ if (b != from) {
+ b.brokeredSelect(ranges, selected);
+ }
+ }
+ }
+ finally {
+ this.dispatching = false;
+ }
+ }
+}
+
+SelectionBroker.prototype.clear = function(from) {
+ this.lastDispatchingHandler = null;
+ if (!this.dispatching) {
+ try {
+ this.dispatching = true;
+ this.brokers.forEach(function(b) {
+ if (b != from) {
+ b.brokeredClear();
+ }
+ });
+ } finally {
+ this.dispatching = false;
+ }
+ }
+}
« no previous file with comments | « tools/turbolizer/selection.js ('k') | tools/turbolizer/text-view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698