| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2015 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. |
| --> |
| |
| <link rel="import" href="/perf_insights/mre/function_handle.html"> |
| <link rel="import" href="/tracing/base/range.html"> |
| <link rel="import" href="/tracing/model/helpers/chrome_browser_helper.html"> |
| <link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html"> |
| <link rel="import" href="/tracing/value/value.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tr.exportTo('pie', function() { |
| function mapStartupInfo(result, model) { |
| var startupIRs = model.userModel.expectations.filter(function(ir) { |
| return ir instanceof tr.model.um.LoadExpectation && |
| ir.initiatorTitle === tr.model.um.LOAD_SUBTYPE_NAMES.STARTUP; |
| }); |
| // Find the Startup IRs in the browser and renderer processes. |
| var ChromeBrowserHelper = tr.model.helpers.ChromeBrowserHelper; |
| var ChromeRendererHelper = tr.model.helpers.ChromeRendererHelper; |
| var browser_startup = new tr.b.Range(); |
| var renderer_startup = new tr.b.Range(); |
| startupIRs.forEach(function(ir) { |
| ir.associatedEvents.toArray().forEach(function(event) { |
| if (!event.getProcess) |
| return; |
| var process = event.getProcess(); |
| var end = event.start + event.duration; |
| if (ChromeBrowserHelper.isBrowserProcess(process)) |
| event.addBoundsToRange(browser_startup); |
| if (ChromeRendererHelper.isRenderProcess(process)) |
| event.addBoundsToRange(renderer_startup); |
| }); |
| }); |
| |
| if (browser_startup.isEmpty && renderer_startup.isEmpty) { |
| result.addPair('startup_info', null); |
| } else { |
| result.addPair( |
| 'startup_info', |
| { |
| 'browserStartup': browser_startup, |
| 'rendererStartup': renderer_startup |
| }); |
| } |
| } |
| |
| pi.FunctionRegistry.register(mapStartupInfo); |
| |
| // Exporting for tests. |
| return { |
| mapStartupInfoForTest: mapStartupInfo |
| }; |
| }); |
| </script> |