Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Side by Side Diff: Source/devtools/front_end/CountersGraph.js

Issue 196523006: [DevTools]Abstract Counter and CounterUIBase (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/MemoryStatistics.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 * @param {!WebInspector.TimelineModeViewDelegate} delegate 35 * @param {!WebInspector.TimelineModeViewDelegate} delegate
36 * @param {!WebInspector.TimelineModel} model 36 * @param {!WebInspector.TimelineModel} model
37 */ 37 */
38 WebInspector.CountersGraph = function(delegate, model) 38 WebInspector.CountersGraph = function(delegate, model)
39 { 39 {
40 WebInspector.MemoryStatistics.call(this, delegate, model); 40 WebInspector.MemoryStatistics.call(this, delegate, model);
41 } 41 }
42 42
43 /** 43 /**
44 * @constructor 44 * @constructor
45 * @extends {WebInspector.CounterUIBase} 45 * @extends {WebInspector.MemoryCounterUIBase}
46 * @param {!WebInspector.CountersGraph} memoryCountersPane 46 * @param {!WebInspector.CountersGraph} memoryCountersPane
47 * @param {string} title 47 * @param {string} title
48 * @param {string} currentValueLabel 48 * @param {string} currentValueLabel
49 * @param {!string} color 49 * @param {!string} color
50 * @param {!WebInspector.MemoryStatistics.Counter} counter 50 * @param {!WebInspector.Counter} counter
51 */ 51 */
52 WebInspector.CounterUI = function(memoryCountersPane, title, currentValueLabel, color, counter) 52 WebInspector.MemoryCounterUI = function(memoryCountersPane, title, currentValueL abel, color, counter)
53 { 53 {
54 WebInspector.CounterUIBase.call(this, memoryCountersPane, title, color, coun ter) 54 WebInspector.MemoryCounterUIBase.call(this, memoryCountersPane, title, color , counter)
55 this._range = this._swatch.element.createChild("span"); 55 this._range = this._swatch.element.createChild("span");
56 56
57 this._value = memoryCountersPane._currentValuesBar.createChild("span", "memo ry-counter-value"); 57 this._value = memoryCountersPane._currentValuesBar.createChild("span", "memo ry-counter-value");
58 this._value.style.color = color; 58 this._value.style.color = color;
59 this._currentValueLabel = currentValueLabel; 59 this._currentValueLabel = currentValueLabel;
60 this._marker = memoryCountersPane._canvasContainer.createChild("div", "memor y-counter-marker"); 60 this._marker = memoryCountersPane._canvasContainer.createChild("div", "memor y-counter-marker");
61 this._marker.style.backgroundColor = color; 61 this._marker.style.backgroundColor = color;
62 this.clearCurrentValueAndMarker(); 62 this.clearCurrentValueAndMarker();
63 63
64 this.graphColor = color; 64 this.graphColor = color;
65 this.graphYValues = []; 65 this.graphYValues = [];
66 } 66 }
67 67
68 WebInspector.CounterUI.prototype = { 68 WebInspector.MemoryCounterUI.prototype = {
69 reset: function() 69 reset: function()
70 { 70 {
71 this._range.textContent = ""; 71 this._range.textContent = "";
72 }, 72 },
73 73
74 /** 74 /**
75 * @param {number} minValue 75 * @param {number} minValue
76 * @param {number} maxValue 76 * @param {number} maxValue
77 */ 77 */
78 setRange: function(minValue, maxValue) 78 setRange: function(minValue, maxValue)
79 { 79 {
80 this._range.textContent = WebInspector.UIString("[%d:%d]", minValue, max Value); 80 this._range.textContent = WebInspector.UIString("[%d:%d]", minValue, max Value);
81 }, 81 },
82 82
83 __proto__: WebInspector.CounterUIBase.prototype 83 __proto__: WebInspector.MemoryCounterUIBase.prototype
84 } 84 }
85 85
86 86
87 WebInspector.CountersGraph.prototype = { 87 WebInspector.CountersGraph.prototype = {
88 _createCurrentValuesBar: function() 88 _createCurrentValuesBar: function()
89 { 89 {
90 this._currentValuesBar = this._graphsContainer.createChild("div"); 90 this._currentValuesBar = this._graphsContainer.createChild("div");
91 this._currentValuesBar.id = "counter-values-bar"; 91 this._currentValuesBar.id = "counter-values-bar";
92 this._graphsContainer.classList.add("dom-counters"); 92 this._graphsContainer.classList.add("dom-counters");
93 }, 93 },
(...skipping 10 matching lines...) Expand all
104 }, 104 },
105 105
106 /** 106 /**
107 * @param {string} uiName 107 * @param {string} uiName
108 * @param {string} uiValueTemplate 108 * @param {string} uiValueTemplate
109 * @param {string} color 109 * @param {string} color
110 * @param {string} protocolName 110 * @param {string} protocolName
111 */ 111 */
112 _createCounter: function(uiName, uiValueTemplate, color, protocolName) 112 _createCounter: function(uiName, uiValueTemplate, color, protocolName)
113 { 113 {
114 var counter = new WebInspector.MemoryStatistics.Counter(protocolName); 114 var counter = new WebInspector.Counter(protocolName);
115 this._counters.push(counter); 115 this._counters.push(counter);
116 this._counterUI.push(new WebInspector.CounterUI(this, uiName, uiValueTem plate, color, counter)); 116 this._counterUI.push(new WebInspector.MemoryCounterUI(this, uiName, uiVa lueTemplate, color, counter));
117 }, 117 },
118 118
119 /** 119 /**
120 * @param {!WebInspector.TimelineModel.Record} record 120 * @param {!WebInspector.TimelineModel.Record} record
121 */ 121 */
122 addRecord: function(record) 122 addRecord: function(record)
123 { 123 {
124 /** 124 /**
125 * @param {!WebInspector.TimelineModel.Record} record 125 * @param {!WebInspector.TimelineModel.Record} record
126 * @this {!WebInspector.CountersGraph} 126 * @this {!WebInspector.CountersGraph}
(...skipping 12 matching lines...) Expand all
139 }, 139 },
140 140
141 draw: function() 141 draw: function()
142 { 142 {
143 WebInspector.MemoryStatistics.prototype.draw.call(this); 143 WebInspector.MemoryStatistics.prototype.draw.call(this);
144 for (var i = 0; i < this._counterUI.length; i++) 144 for (var i = 0; i < this._counterUI.length; i++)
145 this._drawGraph(this._counterUI[i]); 145 this._drawGraph(this._counterUI[i]);
146 }, 146 },
147 147
148 /** 148 /**
149 * @param {!WebInspector.CounterUIBase} counterUI 149 * @param {!WebInspector.MemoryCounterUIBase} counterUI
150 */ 150 */
151 _drawGraph: function(counterUI) 151 _drawGraph: function(counterUI)
152 { 152 {
153 var canvas = this._canvas; 153 var canvas = this._canvas;
154 var ctx = canvas.getContext("2d"); 154 var ctx = canvas.getContext("2d");
155 var width = canvas.width; 155 var width = canvas.width;
156 var height = this._clippedHeight; 156 var height = this._clippedHeight;
157 var originY = this._originY; 157 var originY = this._originY;
158 var counter = counterUI.counter; 158 var counter = counterUI.counter;
159 var values = counter.values; 159 var values = counter.values;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 ctx.lineWidth = 1; 204 ctx.lineWidth = 1;
205 ctx.strokeStyle = counterUI.graphColor; 205 ctx.strokeStyle = counterUI.graphColor;
206 ctx.stroke(); 206 ctx.stroke();
207 ctx.closePath(); 207 ctx.closePath();
208 ctx.restore(); 208 ctx.restore();
209 }, 209 },
210 210
211 __proto__: WebInspector.MemoryStatistics.prototype 211 __proto__: WebInspector.MemoryStatistics.prototype
212 } 212 }
213 213
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/MemoryStatistics.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698