1d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# Copyright 2013 The Chromium Authors. All rights reserved. 2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# found in the LICENSE file. 4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)from telemetry.core.heap import chrome_js_heap_snapshot_parser 6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 76e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)class Model(object): 9d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) """ The heap snapshot model is a set of LiveHeapObjects. The LiveHeapObjects 10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) contain the RetainingEdge objects describing the relationships between the 11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) LiveHeapObjects.""" 12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) def __init__(self, raw_data): 14d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) if not chrome_js_heap_snapshot_parser.ChromeJsHeapSnapshotParser.CanImport( 15d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) raw_data): 16d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) raise ValueError("Cannot import snapshot data") 17d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) parser = chrome_js_heap_snapshot_parser.ChromeJsHeapSnapshotParser(raw_data) 18d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self._all_live_heap_objects = parser.GetAllLiveHeapObjects() 19d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 20d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) @property 21d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) def all_live_heap_objects(self): 22d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return self._all_live_heap_objects 23