1<!DOCTYPE html> 2<!-- 3Copyright (c) 2013 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<link rel="import" href="/tracing/extras/chrome/cc/tile.html"> 8 9<script> 10'use strict'; 11 12tr.exportTo('tr.e.cc', function() { 13 14 var knownRasterTaskNames = [ 15 'TileManager::RunRasterTask', 16 'RasterWorkerPoolTaskImpl::RunRasterOnThread', 17 'RasterWorkerPoolTaskImpl::Raster', 18 'RasterTaskImpl::Raster', 19 'cc::RasterTask', 20 'RasterTask' 21 ]; 22 23 var knownAnalysisTaskNames = [ 24 'TileManager::RunAnalyzeTask', 25 'RasterWorkerPoolTaskImpl::RunAnalysisOnThread', 26 'RasterWorkerPoolTaskImpl::Analyze', 27 'RasterTaskImpl::Analyze', 28 'cc::AnalyzeTask', 29 'AnalyzeTask' 30 ]; 31 32 function getTileFromRasterTaskSlice(slice) { 33 if (!(isSliceDoingRasterization(slice) || isSliceDoingAnalysis(slice))) 34 return undefined; 35 36 var tileData; 37 if (slice.args.data) 38 tileData = slice.args.data; 39 else 40 tileData = slice.args.tileData; 41 if (tileData === undefined) 42 return undefined; 43 if (tileData.tile_id) 44 return tileData.tile_id; 45 46 var tile = tileData.tileId; 47 if (!(tile instanceof tr.e.cc.TileSnapshot)) 48 return undefined; 49 return tileData.tileId; 50 } 51 52 function isSliceDoingRasterization(slice) { 53 if (knownRasterTaskNames.indexOf(slice.title) !== -1) 54 return true; 55 return false; 56 } 57 58 function isSliceDoingAnalysis(slice) { 59 if (knownAnalysisTaskNames.indexOf(slice.title) !== -1) 60 return true; 61 return false; 62 } 63 64 return { 65 getTileFromRasterTaskSlice: getTileFromRasterTaskSlice, 66 isSliceDoingRasterization: isSliceDoingRasterization, 67 isSliceDoingAnalysis: isSliceDoingAnalysis 68 }; 69}); 70</script> 71