OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @extends {WebInspector.CountersGraph} | 33 * @extends {WebInspector.CountersGraph} |
34 * @implements {WebInspector.TimelineModeView} | 34 * @implements {WebInspector.TimelineModeView} |
35 * @param {!WebInspector.TimelineModeViewDelegate} delegate | 35 * @param {!WebInspector.TimelineModeViewDelegate} delegate |
36 * @param {!WebInspector.TimelineModel} model | 36 * @param {!WebInspector.TimelineModel} model |
| 37 * @param {!WebInspector.TimelineUIUtils} uiUtils |
37 */ | 38 */ |
38 WebInspector.MemoryCountersGraph = function(delegate, model) | 39 WebInspector.MemoryCountersGraph = function(delegate, model, uiUtils) |
39 { | 40 { |
40 WebInspector.CountersGraph.call(this, WebInspector.UIString("MEMORY"), deleg
ate, model); | 41 WebInspector.CountersGraph.call(this, WebInspector.UIString("MEMORY"), deleg
ate, model); |
| 42 this._uiUtils = uiUtils; |
41 this._countersByName = {}; | 43 this._countersByName = {}; |
42 this._countersByName["jsHeapSizeUsed"] = this.createCounter(WebInspector.UIS
tring("Used JS Heap"), WebInspector.UIString("JS Heap Size: %d"), "hsl(220, 90%,
43%)"); | 44 this._countersByName["jsHeapSizeUsed"] = this.createCounter(WebInspector.UIS
tring("Used JS Heap"), WebInspector.UIString("JS Heap Size: %d"), "hsl(220, 90%,
43%)"); |
43 this._countersByName["documents"] = this.createCounter(WebInspector.UIString
("Documents"), WebInspector.UIString("Documents: %d"), "hsl(0, 90%, 43%)"); | 45 this._countersByName["documents"] = this.createCounter(WebInspector.UIString
("Documents"), WebInspector.UIString("Documents: %d"), "hsl(0, 90%, 43%)"); |
44 this._countersByName["nodes"] = this.createCounter(WebInspector.UIString("No
des"), WebInspector.UIString("Nodes: %d"), "hsl(120, 90%, 43%)"); | 46 this._countersByName["nodes"] = this.createCounter(WebInspector.UIString("No
des"), WebInspector.UIString("Nodes: %d"), "hsl(120, 90%, 43%)"); |
45 this._countersByName["jsEventListeners"] = this.createCounter(WebInspector.U
IString("Listeners"), WebInspector.UIString("Listeners: %d"), "hsl(38, 90%, 43%)
"); | 47 this._countersByName["jsEventListeners"] = this.createCounter(WebInspector.U
IString("Listeners"), WebInspector.UIString("Listeners: %d"), "hsl(38, 90%, 43%)
"); |
46 if (WebInspector.experimentsSettings.gpuTimeline.isEnabled()) { | 48 if (WebInspector.experimentsSettings.gpuTimeline.isEnabled()) { |
47 this._gpuMemoryCounter = this.createCounter(WebInspector.UIString("GPU M
emory"), WebInspector.UIString("GPU Memory [KB]: %d"), "hsl(300, 90%, 43%)"); | 49 this._gpuMemoryCounter = this.createCounter(WebInspector.UIString("GPU M
emory"), WebInspector.UIString("GPU Memory [KB]: %d"), "hsl(300, 90%, 43%)"); |
48 this._countersByName["gpuMemoryUsedKB"] = this._gpuMemoryCounter; | 50 this._countersByName["gpuMemoryUsedKB"] = this._gpuMemoryCounter; |
49 } | 51 } |
50 } | 52 } |
(...skipping 11 matching lines...) Expand all Loading... |
62 * @param {!WebInspector.TimelineModel.Record} record | 64 * @param {!WebInspector.TimelineModel.Record} record |
63 */ | 65 */ |
64 addRecord: function(record) | 66 addRecord: function(record) |
65 { | 67 { |
66 /** | 68 /** |
67 * @param {!WebInspector.TimelineModel.Record} record | 69 * @param {!WebInspector.TimelineModel.Record} record |
68 * @this {!WebInspector.MemoryCountersGraph} | 70 * @this {!WebInspector.MemoryCountersGraph} |
69 */ | 71 */ |
70 function addStatistics(record) | 72 function addStatistics(record) |
71 { | 73 { |
72 var counters = record.counters(); | 74 var counters = this._uiUtils.countersForRecord(record); |
73 if (!counters) | 75 if (!counters) |
74 return; | 76 return; |
75 for (var name in counters) { | 77 for (var name in counters) { |
76 var counter = this._countersByName[name]; | 78 var counter = this._countersByName[name]; |
77 if (counter) | 79 if (counter) |
78 counter.appendSample(record.endTime() || record.startTime(),
counters[name]); | 80 counter.appendSample(record.endTime() || record.startTime(),
counters[name]); |
79 } | 81 } |
80 | 82 |
81 var gpuMemoryLimitCounterName = "gpuMemoryLimitKB"; | 83 var gpuMemoryLimitCounterName = "gpuMemoryLimitKB"; |
82 if (this._gpuMemoryCounter && (gpuMemoryLimitCounterName in counters
)) | 84 if (this._gpuMemoryCounter && (gpuMemoryLimitCounterName in counters
)) |
83 this._gpuMemoryCounter.setLimit(counters[gpuMemoryLimitCounterNa
me]); | 85 this._gpuMemoryCounter.setLimit(counters[gpuMemoryLimitCounterNa
me]); |
84 } | 86 } |
85 WebInspector.TimelineModel.forAllRecords([record], null, addStatistics.b
ind(this)); | 87 WebInspector.TimelineModel.forAllRecords([record], null, addStatistics.b
ind(this)); |
86 this.scheduleRefresh(); | 88 this.scheduleRefresh(); |
87 }, | 89 }, |
88 | 90 |
89 refreshRecords: function() | 91 refreshRecords: function() |
90 { | 92 { |
91 this.reset(); | 93 this.reset(); |
92 var records = this._model.records(); | 94 var records = this._model.records(); |
93 for (var i = 0; i < records.length; ++i) | 95 for (var i = 0; i < records.length; ++i) |
94 this.addRecord(records[i]); | 96 this.addRecord(records[i]); |
95 }, | 97 }, |
96 | 98 |
97 __proto__: WebInspector.CountersGraph.prototype | 99 __proto__: WebInspector.CountersGraph.prototype |
98 } | 100 } |
OLD | NEW |