1<!DOCTYPE html> 2<!-- 3Copyright (c) 2015 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/perf_insights/function_handle.html"> 9<link rel="import" href="/tracing/base/range.html"> 10<link rel="import" href="/tracing/model/helpers/chrome_browser_helper.html"> 11<link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html"> 12<link rel="import" href="/tracing/value/value.html"> 13 14<script> 15'use strict'; 16 17tr.exportTo('pie', function() { 18 function mapStartupInfo(result, model) { 19 var startupIRs = model.userModel.expectations.filter(function(ir) { 20 return ir instanceof tr.model.um.LoadExpectation && 21 ir.initiatorTitle === tr.model.um.LOAD_SUBTYPE_NAMES.STARTUP; 22 }); 23 // Find the Startup IRs in the browser and renderer processes. 24 var ChromeBrowserHelper = tr.model.helpers.ChromeBrowserHelper; 25 var ChromeRendererHelper = tr.model.helpers.ChromeRendererHelper; 26 var browser_startup = new tr.b.Range(); 27 var renderer_startup = new tr.b.Range(); 28 startupIRs.forEach(function(ir) { 29 ir.associatedEvents.toArray().forEach(function(event) { 30 if (!event.getProcess) 31 return; 32 var process = event.getProcess(); 33 var end = event.start + event.duration; 34 if (ChromeBrowserHelper.isBrowserProcess(process)) 35 event.addBoundsToRange(browser_startup); 36 if (ChromeRendererHelper.isRenderProcess(process)) 37 event.addBoundsToRange(renderer_startup); 38 }); 39 }); 40 41 if (browser_startup.isEmpty && renderer_startup.isEmpty) { 42 result.addPair('startup_info', null); 43 } else { 44 result.addPair( 45 'startup_info', 46 { 47 'browserStartup': browser_startup, 48 'rendererStartup': renderer_startup 49 }); 50 } 51 } 52 53 pi.FunctionRegistry.register(mapStartupInfo); 54 55 // Exporting for tests. 56 return { 57 mapStartupInfoForTest: mapStartupInfo 58 }; 59}); 60</script> 61