| 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..bbd1a2953265c33107223bc2aa6a16346c4624ad
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js
|
| @@ -0,0 +1,45 @@
|
| +// 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;
|
| + if (frame.url)
|
| + name = ProductRegistry.nameForUrl(new Common.ParsedURL(frame.url));
|
| + if (name)
|
| + return name;
|
| + // We are not caching the frame url result because it may change.
|
| + var symbol = ConsoleFrameProductLookup.ProductLookup._consoleProductFrameNameSymbol;
|
| + if (symbol in frame)
|
| + return frame[symbol];
|
| + frame[symbol] = ConsoleFrameProductLookup.ProductLookup._lookupFrameStacktraceName(frame);
|
| + return frame[symbol];
|
| + }
|
| +
|
| + /**
|
| + * @param {!SDK.ResourceTreeFrame} frame
|
| + * @return {?string}
|
| + */
|
| + static _lookupFrameStacktraceName(frame) {
|
| + var name;
|
| + for (var stackTrace = frame.creationStackTrace(); stackTrace; stackTrace = frame.parent) {
|
| + for (var callFrame of stackTrace.callFrames) {
|
| + if (callFrame.url)
|
| + name = ProductRegistry.nameForUrl(new Common.ParsedURL(callFrame.url));
|
| + if (name)
|
| + return name;
|
| + }
|
| + }
|
| + return null;
|
| + }
|
| +};
|
| +
|
| +ConsoleFrameProductLookup.ProductLookup._consoleProductFrameNameSymbol = Symbol('ConsoleProductFrameName');
|
|
|