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

Side by Side Diff: chrome/browser/resources/net_internals/details_view.js

Issue 8474001: Add a timeline view to about:net-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Comment fix Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var DetailsView = (function() { 5 var DetailsView = (function() {
6 'use strict'; 6 'use strict';
7 7
8 // We inherit from VerticalSplitView. 8 // We inherit from DivView.
9 var superClass = VerticalSplitView; 9 var superClass = DivView;
10 10
11 /** 11 /**
12 * The DetailsView handles the tabbed view that displays either the "log" or 12 * The DetailsView displays the "log" view. This class keeps track of the
13 * "timeline" view. This class keeps track of what the current view is, and 13 * selected SourceEntries, and repaints when they change.
14 * invalidates the specific view each time the selected data has changed.
15 * 14 *
16 * @constructor 15 * @constructor
17 */ 16 */
18 function DetailsView(tabHandlesContainerId, 17 function DetailsView(boxId) {
19 logTabId, 18 superClass.call(this, boxId);
20 timelineTabId, 19 this.sourceEntries_ = [];
21 logBoxId,
22 timelineBoxId) {
23 var tabSwitcher = new TabSwitcherView();
24
25 superClass.call(this, new DivView(tabHandlesContainerId), tabSwitcher);
26
27 this.tabSwitcher_ = tabSwitcher;
28
29 this.logView_ = new DetailsLogView(logBoxId);
30 this.timelineView_ = new DetailsTimelineView(timelineBoxId);
31
32 this.tabSwitcher_.addTab(logTabId, this.logView_, true, true);
33 this.tabSwitcher_.addTab(timelineTabId, this.timelineView_, true, true);
34
35 // Default to the log view.
36 this.tabSwitcher_.switchToTab(logTabId, null);
37 } 20 }
38 21
39 // The delay between updates to repaint. 22 // The delay between updates to repaint.
40 var REPAINT_TIMEOUT_MS = 50; 23 var REPAINT_TIMEOUT_MS = 50;
41 24
42 DetailsView.prototype = { 25 DetailsView.prototype = {
43 // Inherit the superclass's methods. 26 // Inherit the superclass's methods.
44 __proto__: superClass.prototype, 27 __proto__: superClass.prototype,
45 28
46 /** 29 setData: function(sourceEntries) {
47 * Updates the data this view is using.
48 */
49 setData: function(currentData) {
50 // Make a copy of the array (in case the caller mutates it), and sort it 30 // Make a copy of the array (in case the caller mutates it), and sort it
51 // by the source ID. 31 // by the source ID.
52 var sortedCurrentData = createSortedCopy(currentData); 32 this.sourceEntries_ = createSortedCopy(sourceEntries);
53 33
54 // TODO(eroman): Should not access private members of TabSwitcherView. 34 // Repaint the view.
55 for (var i = 0; i < this.tabSwitcher_.tabs_.length; ++i) 35 if (this.isVisible() && !this.outstandingRepaint_) {
56 this.tabSwitcher_.tabs_[i].contentView.setData(sortedCurrentData); 36 this.outstandingRepaint_ = true;
37 window.setTimeout(this.repaint.bind(this),
38 REPAINT_TIMEOUT_MS);
39 }
40 },
41
42 repaint: function() {
43 this.outstandingRepaint_ = false;
44 this.getNode().innerHTML = '';
45 PaintLogView(this.sourceEntries_, this.getNode());
46 },
47
48 show: function(isVisible) {
49 superClass.prototype.show.call(this, isVisible);
50 if (isVisible) {
51 this.repaint();
52 } else {
53 this.getNode().innerHTML = '';
54 }
57 } 55 }
58 }; 56 };
59 57
60 function createSortedCopy(origArray) { 58 function createSortedCopy(origArray) {
61 var sortedArray = origArray.slice(0); 59 var sortedArray = origArray.slice(0);
62 sortedArray.sort(function(a, b) { 60 sortedArray.sort(function(a, b) {
63 return a.getSourceId() - b.getSourceId(); 61 return a.getSourceId() - b.getSourceId();
64 }); 62 });
65 return sortedArray; 63 return sortedArray;
66 } 64 }
67 65
68 //---------------------------------------------------------------------------
69
70 var DetailsSubView = (function() {
71 // We inherit from DivView.
72 var superClass = DivView;
73
74 /**
75 * Base class for the Log view and Timeline view.
76 *
77 * @constructor
78 */
79 function DetailsSubView(boxId) {
80 superClass.call(this, boxId);
81 this.sourceEntries_ = [];
82 }
83
84 DetailsSubView.prototype = {
85 // Inherit the superclass's methods.
86 __proto__: superClass.prototype,
87
88 setData: function(sourceEntries) {
89 this.sourceEntries_ = sourceEntries;
90
91 // Repaint the view.
92 if (this.isVisible() && !this.outstandingRepaint_) {
93 this.outstandingRepaint_ = true;
94 window.setTimeout(this.repaint.bind(this),
95 REPAINT_TIMEOUT_MS);
96 }
97 },
98
99 repaint: function() {
100 this.outstandingRepaint_ = false;
101 this.getNode().innerHTML = '';
102 },
103
104 show: function(isVisible) {
105 superClass.prototype.show.call(this, isVisible);
106 if (isVisible) {
107 this.repaint();
108 } else {
109 this.getNode().innerHTML = '';
110 }
111 }
112 };
113
114 return DetailsSubView;
115 })();
116
117 //---------------------------------------------------------------------------
118
119 var DetailsLogView = (function() {
120 // We inherit from DetailsSubView.
121 var superClass = DetailsSubView;
122
123 /**
124 * Subview that is displayed in the log tab.
125 * @constructor
126 */
127 function DetailsLogView(boxId) {
128 superClass.call(this, boxId);
129 }
130
131 DetailsLogView.prototype = {
132 // Inherit the superclass's methods.
133 __proto__: superClass.prototype,
134
135 repaint: function() {
136 superClass.prototype.repaint.call(this);
137 PaintLogView(this.sourceEntries_, this.getNode());
138 }
139 };
140
141 return DetailsLogView;
142 })();
143
144 //---------------------------------------------------------------------------
145
146 var DetailsTimelineView = (function() {
147 // We inherit from DetailsSubView.
148 var superClass = DetailsSubView;
149
150 /**
151 * Subview that is displayed in the timeline tab.
152 * @constructor
153 */
154 function DetailsTimelineView(boxId) {
155 superClass.call(this, boxId);
156 }
157
158 DetailsTimelineView.prototype = {
159 // Inherit the superclass's methods.
160 __proto__: superClass.prototype,
161
162 repaint: function() {
163 superClass.prototype.repaint.call(this);
164 PaintTimelineView(this.sourceEntries_, this.getNode());
165 }
166 };
167
168 return DetailsTimelineView;
169 })();
170
171 return DetailsView; 66 return DetailsView;
172 })(); 67 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/category_tabs.html ('k') | chrome/browser/resources/net_internals/dns_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698