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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js

Issue 2796703002: [Devtools] Execution context in console shows product experiment (Closed)
Patch Set: [Devtools] Execution context in console shows product experiment Created 3 years, 9 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/console_frame_product_lookup/ConsoleFrameProductLookup.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js b/third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js
new file mode 100644
index 0000000000000000000000000000000000000000..5d3f469a65b80e7829648a8de00591f1479cb5b6
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js
@@ -0,0 +1,48 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+/**
+ * @implements {Console.ConsoleFrameNameLookupInterface}
+ */
+ConsoleFrameProductLookup.ProductLookup = class {
+ /**
+ * @override
+ * @param {!SDK.ResourceTreeFrame} frame
+ * @return {?string}
+ */
+ nameForFrame(frame) {
+ var name;
+ var frameParsedURL = new Common.ParsedURL(frame.url);
luoe 2017/04/04 18:31:02 nit, can we move this inside the 'if' block, same
pfeldman 2017/04/04 19:03:16 +1. also, we seem to not be saving much via passin
allada 2017/04/05 01:49:46 Done.
allada 2017/04/05 01:49:46 I wanted to keep it using a url because right now
+ if (frame.url)
+ name = ProductRegistry.nameForUrl(frameParsedURL);
+ if (name)
+ return name;
+ // We are not caching the frame url result because it may change.
pfeldman 2017/04/04 19:03:16 What does this mean?
allada 2017/04/05 01:49:46 The frame's URL may change, but the creator of the
+ var symbol = ConsoleFrameProductLookup.ProductLookup._consoleProductFrameNameSymbol;
+ if (symbol in frame)
+ return frame[symbol];
+ frame[symbol] = this._lookupFrameStacktraceName(frame);
+ return frame[symbol];
+ }
+
+ /**
+ * @param {!SDK.ResourceTreeFrame} frame
+ * @return {?string}
+ */
+ _lookupFrameStacktraceName(frame) {
pfeldman 2017/04/04 19:03:16 Looks like static method.
allada 2017/04/05 01:49:46 Done.
+ var stackTrace = frame.creationStackTrace();
+ var name;
+ while (stackTrace) {
caseq 2017/04/04 18:59:40 nit: consider for instead of while.
allada 2017/04/05 01:49:46 Done.
+ for (var stack of stackTrace.callFrames) {
luoe 2017/04/04 18:31:02 Can we rename 'stack' to 'callFrame' here?
allada 2017/04/05 01:49:45 Done.
+ if (stack.url)
+ name = ProductRegistry.nameForUrl(new Common.ParsedURL(stack.url));
+ if (name)
+ return name;
+ }
+ stackTrace = frame.parent;
caseq 2017/04/04 18:59:40 frame.parent does not exist. Also, what type do yo
allada 2017/04/05 01:49:45 Sorry, I meant stackTrace.parent. Fixed. It should
+ }
+ return null;
+ }
+};
+
+ConsoleFrameProductLookup.ProductLookup._consoleProductFrameNameSymbol = Symbol('ConsoleProductFrameName');

Powered by Google App Engine
This is Rietveld 408576698