Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js |
| index 9202ce2b689124bea4772458b3189c5749e921c8..39ef21abbe2501e2db7d0e888e7f61e1a347161f 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js |
| @@ -333,6 +333,34 @@ Timeline.TimelineUIUtils = class { |
| } |
| /** |
| + * @param {!ProductRegistry.Registry} productRegistry |
| + * @param {!TimelineModel.TimelineModel} model |
| + * @param {!Map<string, string>} urlToColorCache |
| + * @param {!SDK.TracingModel.Event} event |
| + * @return {string} |
| + */ |
| + static eventColorByProduct(productRegistry, model, urlToColorCache, event) { |
| + var url = Timeline.TimelineUIUtils.eventURL(event) || ''; |
| + var color = urlToColorCache.get(url); |
| + if (!color) { |
| + var defaultColor = '#f2ecdc'; |
| + var parsedURL = url.asParsedURL(); |
| + if (!parsedURL) |
| + return defaultColor; |
| + var name = productRegistry && productRegistry.nameForUrl(parsedURL); |
| + if (!name) { |
| + name = parsedURL.host; |
| + var rootFrames = model.rootFrames(); |
| + if (rootFrames.some(pageFrame => new Common.ParsedURL(pageFrame.url).host === name)) |
| + return defaultColor; |
|
caseq
2017/05/22 23:43:35
Why don't we cache it?
alph
2017/05/24 00:53:44
Done.
|
| + } |
| + color = name ? ProductRegistry.BadgePool.colorForEntryName(name) : defaultColor; |
| + urlToColorCache.set(url, color); |
| + } |
| + return color; |
| + } |
| + |
| + /** |
| * @param {!SDK.TracingModel.Event} event |
| * @return {string} |
| */ |