storage.js revision effb81e5f8246d0db0270817048dc992db66e9fb
1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5storage = new (function() { 6 7this.table_ = null; 8this.tableData_ = null; 9 10this.onDomReady_ = function() { 11 // Initialize the toolbar. 12 $('#storage-profile-mmaps').button({icons:{primary: 'ui-icon-image'}}) 13 .click(this.profileMmapForSelectedSnapshots.bind(this)); 14 $('#storage-dump-mmaps').button({icons:{primary: 'ui-icon-calculator'}}) 15 .click(this.dumpMmapForSelectedSnapshot_.bind(this)); 16 $('#storage-profile-native').button({icons:{primary: 'ui-icon-image'}}) 17 .click(this.profileNativeForSelectedSnapshots.bind(this)); 18 19 // Create the table. 20 this.table_ = new google.visualization.Table($('#storage-table')[0]); 21}; 22 23this.reload = function() { 24 webservice.ajaxRequest('/storage/list', this.onListAjaxResponse_.bind(this)); 25} 26 27this.onListAjaxResponse_ = function(data) { 28 this.tableData_ = new google.visualization.DataTable(data); 29 this.redraw(); 30}; 31 32this.profileMmapForSelectedSnapshots = function() { 33 // Generates a mmap profile for the selected snapshots. 34 var sel = this.table_.getSelection(); 35 if (!sel.length || !this.tableData_) 36 return; 37 var archiveName = null; 38 var snapshots = []; 39 40 for (var i = 0; i < sel.length; ++i) { 41 var row = sel[i].row; 42 var curArchive = this.tableData_.getValue(row, 0); 43 if (archiveName && curArchive != archiveName){ 44 alert('All the selected snapshots must belong to the same archive!'); 45 return; 46 } 47 archiveName = curArchive; 48 snapshots.push(this.tableData_.getValue(row, 1)); 49 } 50 profiler.profileArchivedMmaps(archiveName, snapshots); 51 rootUi.showTab('prof'); 52}; 53 54this.dumpMmapForSelectedSnapshot_ = function() { 55 var sel = this.table_.getSelection(); 56 if (sel.length != 1) { 57 alert('Please select only one snapshot.') 58 return; 59 } 60 61 var row = sel[0].row; 62 mmap.dumpMmapsFromStorage(this.tableData_.getValue(row, 0), 63 this.tableData_.getValue(row, 1)) 64 rootUi.showTab('mm'); 65}; 66 67this.profileNativeForSelectedSnapshots = function() { 68 69}; 70 71this.redraw = function() { 72 if (!this.tableData_) 73 return; 74 this.table_.draw(this.tableData_); 75}; 76 77$(document).ready(this.onDomReady_.bind(this)); 78 79})();