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

Side by Side Diff: Source/devtools/front_end/network/NetworkPanel.js

Issue 1178563002: DevTools: Refactor network panel overview (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update test. Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 this._filterBar = new WebInspector.FilterBar(); 52 this._filterBar = new WebInspector.FilterBar();
53 this._filtersContainer = this.element.createChild("div", "network-filters-he ader hidden"); 53 this._filtersContainer = this.element.createChild("div", "network-filters-he ader hidden");
54 this._filtersContainer.appendChild(this._filterBar.filtersElement()); 54 this._filtersContainer.appendChild(this._filterBar.filtersElement());
55 this._filterBar.addEventListener(WebInspector.FilterBar.Events.FiltersToggle d, this._onFiltersToggled, this); 55 this._filterBar.addEventListener(WebInspector.FilterBar.Events.FiltersToggle d, this._onFiltersToggled, this);
56 this._filterBar.setName("networkPanel", true); 56 this._filterBar.setName("networkPanel", true);
57 57
58 this._searchableView = new WebInspector.SearchableView(this); 58 this._searchableView = new WebInspector.SearchableView(this);
59 this._searchableView.setPlaceholder(WebInspector.UIString("Find by filename or path")); 59 this._searchableView.setPlaceholder(WebInspector.UIString("Find by filename or path"));
60 this._searchableView.show(this.element); 60 this._searchableView.show(this.element);
61 61
62 this._overview = new WebInspector.NetworkOverview(); 62 // Create top overview component.
63 this._overviewPane = new WebInspector.TimelineOverviewPane("network");
64 this._overviewPane.addEventListener(WebInspector.TimelineOverviewPane.Events .WindowChanged, this._onWindowChanged.bind(this));
65 this._overviewPane.element.id = "network-overview-panel";
66 this._networkOverview = new WebInspector.NetworkOverview();
67 this._overviewPane.setOverviewControls([this._networkOverview]);
68 this._calculator = new WebInspector.NetworkTransferTimeCalculator();
63 69
64 this._splitWidget = new WebInspector.SplitWidget(true, false, "networkPanelS plitViewState"); 70 this._splitWidget = new WebInspector.SplitWidget(true, false, "networkPanelS plitViewState");
65 this._splitWidget.hideMain(); 71 this._splitWidget.hideMain();
66 72
67 this._splitWidget.show(this._searchableView.element); 73 this._splitWidget.show(this._searchableView.element);
68 74
69 this._progressBarContainer = createElement("div"); 75 this._progressBarContainer = createElement("div");
70 this._createToolbarButtons(); 76 this._createToolbarButtons();
71 77
72 /** @type {!WebInspector.NetworkLogView} */ 78 /** @type {!WebInspector.NetworkLogView} */
73 this._networkLogView = new WebInspector.NetworkLogView(this._overview, this. _filterBar, this._progressBarContainer, this._networkLogLargeRowsSetting); 79 this._networkLogView = new WebInspector.NetworkLogView(this._filterBar, this ._progressBarContainer, this._networkLogLargeRowsSetting);
74 this._splitWidget.setSidebarWidget(this._networkLogView); 80 this._splitWidget.setSidebarWidget(this._networkLogView);
75 81
76 this._detailsWidget = new WebInspector.VBox(); 82 this._detailsWidget = new WebInspector.VBox();
77 this._detailsWidget.element.classList.add("network-details-view"); 83 this._detailsWidget.element.classList.add("network-details-view");
78 this._splitWidget.setMainWidget(this._detailsWidget); 84 this._splitWidget.setMainWidget(this._detailsWidget);
79 85
80 this._closeButtonElement = createElementWithClass("div", "network-close-butt on", "dt-close-button"); 86 this._closeButtonElement = createElementWithClass("div", "network-close-butt on", "dt-close-button");
81 this._closeButtonElement.addEventListener("click", this._showRequest.bind(th is, null), false); 87 this._closeButtonElement.addEventListener("click", this._showRequest.bind(th is, null), false);
82 88
83 this._networkLogShowOverviewSetting.addChangeListener(this._toggleShowOvervi ew, this); 89 this._networkLogShowOverviewSetting.addChangeListener(this._toggleShowOvervi ew, this);
84 this._networkLogLargeRowsSetting.addChangeListener(this._toggleLargerRequest s, this); 90 this._networkLogLargeRowsSetting.addChangeListener(this._toggleLargerRequest s, this);
85 this._networkRecordFilmStripSetting.addChangeListener(this._toggleRecordFilm Strip, this); 91 this._networkRecordFilmStripSetting.addChangeListener(this._toggleRecordFilm Strip, this);
86 92
87 this._toggleRecordButton(true); 93 this._toggleRecordButton(true);
88 this._toggleShowOverview(); 94 this._toggleShowOverview();
89 this._toggleLargerRequests(); 95 this._toggleLargerRequests();
90 this._toggleRecordFilmStrip(); 96 this._toggleRecordFilmStrip();
91 this._dockSideChanged(); 97 this._dockSideChanged();
92 98
93 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve nts.DockSideChanged, this._dockSideChanged.bind(this)); 99 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve nts.DockSideChanged, this._dockSideChanged.bind(this));
94 WebInspector.moduleSetting("splitVerticallyWhenDockedToRight").addChangeList ener(this._dockSideChanged.bind(this)); 100 WebInspector.moduleSetting("splitVerticallyWhenDockedToRight").addChangeList ener(this._dockSideChanged.bind(this));
95 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.WillReloadPage, this._willReloadPage, this); 101 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.WillReloadPage, this._willReloadPage, this);
96 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.Load, this._load, this); 102 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.Load, this._load, this);
97 this._networkLogView.addEventListener(WebInspector.NetworkLogView.EventTypes .RequestSelected, this._onRequestSelected, this); 103 this._networkLogView.addEventListener(WebInspector.NetworkLogView.EventTypes .RequestSelected, this._onRequestSelected, this);
98 this._networkLogView.addEventListener(WebInspector.NetworkLogView.EventTypes .SearchCountUpdated, this._onSearchCountUpdated, this); 104 this._networkLogView.addEventListener(WebInspector.NetworkLogView.EventTypes .SearchCountUpdated, this._onSearchCountUpdated, this);
99 this._networkLogView.addEventListener(WebInspector.NetworkLogView.EventTypes .SearchIndexUpdated, this._onSearchIndexUpdated, this); 105 this._networkLogView.addEventListener(WebInspector.NetworkLogView.EventTypes .SearchIndexUpdated, this._onSearchIndexUpdated, this);
106 this._networkLogView.addEventListener(WebInspector.NetworkLogView.EventTypes .UpdateRequest, this._onUpdateRequest, this);
100 107
101 /** 108 /**
102 * @this {WebInspector.NetworkPanel} 109 * @this {WebInspector.NetworkPanel}
103 * @return {?WebInspector.SourceFrame} 110 * @return {?WebInspector.SourceFrame}
104 */ 111 */
105 function sourceFrameGetter() 112 function sourceFrameGetter()
106 { 113 {
107 return this._networkItemView.currentSourceFrame(); 114 return this._networkItemView.currentSourceFrame();
108 } 115 }
109 WebInspector.GoToLineDialog.install(this, sourceFrameGetter.bind(this)); 116 WebInspector.GoToLineDialog.install(this, sourceFrameGetter.bind(this));
110 WebInspector.DataSaverInfobar.maybeShowInPanel(this); 117 WebInspector.DataSaverInfobar.maybeShowInPanel(this);
111 } 118 }
112 119
113 WebInspector.NetworkPanel.prototype = { 120 WebInspector.NetworkPanel.prototype = {
121 /**
122 * @param {!WebInspector.Event} event
123 */
124 _onWindowChanged: function(event)
125 {
126 var startTime = Math.max(this._calculator.minimumBoundary(), event.data. startTime / 1000);
127 var endTime = Math.min(this._calculator.maximumBoundary(), event.data.en dTime / 1000);
128 this._networkLogView.setWindow(startTime, endTime);
129 },
130
114 _createToolbarButtons: function() 131 _createToolbarButtons: function()
115 { 132 {
116 this._recordButton = new WebInspector.ToolbarButton("", "record-toolbar- item"); 133 this._recordButton = new WebInspector.ToolbarButton("", "record-toolbar- item");
117 this._recordButton.addEventListener("click", this._onRecordButtonClicked , this); 134 this._recordButton.addEventListener("click", this._onRecordButtonClicked , this);
118 this._panelToolbar.appendToolbarItem(this._recordButton); 135 this._panelToolbar.appendToolbarItem(this._recordButton);
119 136
120 this._clearButton = new WebInspector.ToolbarButton(WebInspector.UIString ("Clear"), "clear-toolbar-item"); 137 this._clearButton = new WebInspector.ToolbarButton(WebInspector.UIString ("Clear"), "clear-toolbar-item");
121 this._clearButton.addEventListener("click", this._onClearButtonClicked, this); 138 this._clearButton.addEventListener("click", this._onClearButtonClicked, this);
122 this._panelToolbar.appendToolbarItem(this._clearButton); 139 this._panelToolbar.appendToolbarItem(this._clearButton);
123 140
(...skipping 24 matching lines...) Expand all
148 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox); 165 this._panelToolbar.appendToolbarItem(this._disableCacheCheckbox);
149 166
150 this._panelToolbar.appendToolbarItem(new WebInspector.ToolbarItem(this._ progressBarContainer)); 167 this._panelToolbar.appendToolbarItem(new WebInspector.ToolbarItem(this._ progressBarContainer));
151 }, 168 },
152 169
153 /** 170 /**
154 * @param {!WebInspector.Event} event 171 * @param {!WebInspector.Event} event
155 */ 172 */
156 _onRecordButtonClicked: function(event) 173 _onRecordButtonClicked: function(event)
157 { 174 {
158 if (!this._recordButton.toggled()) 175 if (!this._preserveLogCheckbox.checked() && !this._recordButton.toggled( ))
159 this._networkLogView.reset(); 176 this._reset();
160 this._toggleRecordButton(!this._recordButton.toggled()); 177 this._toggleRecordButton(!this._recordButton.toggled());
161 }, 178 },
162 179
163 /** 180 /**
164 * @param {boolean} toggled 181 * @param {boolean} toggled
165 */ 182 */
166 _toggleRecordButton: function(toggled) 183 _toggleRecordButton: function(toggled)
167 { 184 {
168 this._recordButton.setToggled(toggled); 185 this._recordButton.setToggled(toggled);
169 this._recordButton.setTitle(toggled ? WebInspector.UIString("Stop Record ing Network Log") : WebInspector.UIString("Record Network Log")); 186 this._recordButton.setTitle(toggled ? WebInspector.UIString("Stop Record ing Network Log") : WebInspector.UIString("Record Network Log"));
170 this._networkLogView.setRecording(toggled); 187 this._networkLogView.setRecording(toggled);
171 if (!toggled && this._filmStripRecorder) 188 if (!toggled && this._filmStripRecorder)
172 this._filmStripRecorder.stopRecording(this._filmStripAvailable.bind( this)); 189 this._filmStripRecorder.stopRecording(this._filmStripAvailable.bind( this));
173 }, 190 },
174 191
175 /** 192 /**
176 * @param {?WebInspector.FilmStripModel} filmStripModel 193 * @param {?WebInspector.FilmStripModel} filmStripModel
177 */ 194 */
178 _filmStripAvailable: function(filmStripModel) 195 _filmStripAvailable: function(filmStripModel)
179 { 196 {
180 if (!filmStripModel) 197 if (!filmStripModel)
181 return; 198 return;
182 var calculator = this._networkLogView.timeCalculator(); 199 var calculator = this._networkLogView.timeCalculator();
183 this._filmStripView.setModel(filmStripModel, calculator.minimumBoundary( ) * 1000, calculator.boundarySpan() * 1000); 200 this._filmStripView.setModel(filmStripModel, calculator.minimumBoundary( ) * 1000, calculator.boundarySpan() * 1000);
184 this._overview.setFilmStripModel(filmStripModel); 201 this._networkOverview.setFilmStripModel(filmStripModel);
185 for (var frame of filmStripModel.frames()) 202 for (var frame of filmStripModel.frames())
186 this._networkLogView.addFilmStripFrame(frame.timestamp / 1000); 203 this._networkLogView.addFilmStripFrame(frame.timestamp / 1000);
187 }, 204 },
188 205
189 /** 206 /**
190 * @param {!Event} event 207 * @param {!Event} event
191 */ 208 */
192 _onPreserveLogCheckboxChanged: function(event) 209 _onPreserveLogCheckboxChanged: function(event)
193 { 210 {
194 this._networkLogView.setPreserveLog(this._preserveLogCheckbox.checked()) ; 211 this._networkLogView.setPreserveLog(this._preserveLogCheckbox.checked()) ;
195 }, 212 },
196 213
197 /** 214 /**
198 * @param {!WebInspector.Event} event 215 * @param {!WebInspector.Event} event
199 */ 216 */
200 _onClearButtonClicked: function(event) 217 _onClearButtonClicked: function(event)
201 { 218 {
202 this._overview.reset(); 219 this._reset();
220 },
221
222 _reset: function()
223 {
224 this._calculator.reset();
225 this._overviewPane.reset();
203 this._networkLogView.reset(); 226 this._networkLogView.reset();
204 if (this._filmStripView) 227 if (this._filmStripView)
205 this._filmStripView.reset(); 228 this._filmStripView.reset();
206 }, 229 },
207 230
208 /** 231 /**
209 * @param {!WebInspector.Event} event 232 * @param {!WebInspector.Event} event
210 */ 233 */
211 _willReloadPage: function(event) 234 _willReloadPage: function(event)
212 { 235 {
236 if (!this._preserveLogCheckbox.checked())
237 this._reset();
213 this._toggleRecordButton(true); 238 this._toggleRecordButton(true);
214 if (!this._preserveLogCheckbox.checked())
215 this._networkLogView.reset();
216 if (this.isShowing() && this._filmStripRecorder) 239 if (this.isShowing() && this._filmStripRecorder)
217 this._filmStripRecorder.startRecording(); 240 this._filmStripRecorder.startRecording();
218 }, 241 },
219 242
220 /** 243 /**
221 * @param {!WebInspector.Event} event 244 * @param {!WebInspector.Event} event
222 */ 245 */
223 _load: function(event) 246 _load: function(event)
224 { 247 {
225 if (this._filmStripRecorder && this._filmStripRecorder.isRecording()) 248 if (this._filmStripRecorder && this._filmStripRecorder.isRecording())
226 setTimeout(this._toggleRecordButton.bind(this, false), 1000); 249 setTimeout(this._toggleRecordButton.bind(this, false), 1000);
227 }, 250 },
228 251
229 _toggleLargerRequests: function() 252 _toggleLargerRequests: function()
230 { 253 {
231 this._updateUI(); 254 this._updateUI();
232 }, 255 },
233 256
234 _toggleShowOverview: function() 257 _toggleShowOverview: function()
235 { 258 {
236 var toggled = this._networkLogShowOverviewSetting.get(); 259 var toggled = this._networkLogShowOverviewSetting.get();
237 if (toggled) 260 if (toggled)
238 this._overview.show(this._searchableView.element, this._splitWidget. element); 261 this._overviewPane.show(this._searchableView.element, this._splitWid get.element);
239 else 262 else
240 this._overview.detach(); 263 this._overviewPane.detach();
241 this.doResize(); 264 this.doResize();
242 }, 265 },
243 266
244 _toggleRecordFilmStrip: function() 267 _toggleRecordFilmStrip: function()
245 { 268 {
246 var toggled = this._networkRecordFilmStripSetting.get(); 269 var toggled = this._networkRecordFilmStripSetting.get();
247 if (toggled && !this._filmStripRecorder) { 270 if (toggled && !this._filmStripRecorder) {
248 this._filmStripView = new WebInspector.FilmStripView(); 271 this._filmStripView = new WebInspector.FilmStripView();
249 this._filmStripView.element.classList.add("network-film-strip"); 272 this._filmStripView.element.classList.add("network-film-strip");
250 this._filmStripRecorder = new WebInspector.NetworkPanel.FilmStripRec order(this._filmStripView); 273 this._filmStripRecorder = new WebInspector.NetworkPanel.FilmStripRec order(this._filmStripView);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 526
504 appendRevealItem.call(this, request); 527 appendRevealItem.call(this, request);
505 }, 528 },
506 529
507 /** 530 /**
508 * @param {!WebInspector.Event} event 531 * @param {!WebInspector.Event} event
509 */ 532 */
510 _onFilmFrameSelected: function(event) 533 _onFilmFrameSelected: function(event)
511 { 534 {
512 var timestamp = /** @type {number} */ (event.data); 535 var timestamp = /** @type {number} */ (event.data);
513 this._overview.setWindow(0, timestamp / 1000); 536 this._overviewPane.requestWindowTimes(0, timestamp);
514 }, 537 },
515 538
516 /** 539 /**
517 * @param {!WebInspector.Event} event 540 * @param {!WebInspector.Event} event
518 */ 541 */
519 _onFilmFrameEnter: function(event) 542 _onFilmFrameEnter: function(event)
520 { 543 {
521 var timestamp = /** @type {number} */ (event.data); 544 var timestamp = /** @type {number} */ (event.data);
522 this._overview.selectFilmStripFrame(timestamp / 1000); 545 this._networkOverview.selectFilmStripFrame(timestamp);
523 this._networkLogView.selectFilmStripFrame(timestamp / 1000); 546 this._networkLogView.selectFilmStripFrame(timestamp / 1000);
524 }, 547 },
525 548
526 /** 549 /**
527 * @param {!WebInspector.Event} event 550 * @param {!WebInspector.Event} event
528 */ 551 */
529 _onFilmFrameExit: function(event) 552 _onFilmFrameExit: function(event)
530 { 553 {
531 this._overview.clearFilmStripFrame(); 554 this._networkOverview.clearFilmStripFrame();
532 this._networkLogView.clearFilmStripFrame(); 555 this._networkLogView.clearFilmStripFrame();
533 }, 556 },
534 557
558 /**
559 * @param {!WebInspector.Event} event
560 */
561 _onUpdateRequest: function(event)
562 {
563 var request = /** @type {!WebInspector.NetworkRequest} */ (event.data);
564 this._calculator.updateBoundaries(request);
565 // FIXME: Unify all time units across the frontend!
566 this._overviewPane.setBounds(this._calculator.minimumBoundary() * 1000, this._calculator.maximumBoundary() * 1000);
567 this._networkOverview.updateRequest(request);
568 this._overviewPane.update();
569 },
570
535 __proto__: WebInspector.Panel.prototype 571 __proto__: WebInspector.Panel.prototype
536 } 572 }
537 573
538 /** 574 /**
539 * @constructor 575 * @constructor
540 * @implements {WebInspector.ContextMenu.Provider} 576 * @implements {WebInspector.ContextMenu.Provider}
541 */ 577 */
542 WebInspector.NetworkPanel.ContextMenuProvider = function() 578 WebInspector.NetworkPanel.ContextMenuProvider = function()
543 { 579 {
544 } 580 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 { 734 {
699 if (!this._target) 735 if (!this._target)
700 return; 736 return;
701 737
702 this._target.tracingManager.stop(); 738 this._target.tracingManager.stop();
703 this._target = null; 739 this._target = null;
704 this._callback = callback; 740 this._callback = callback;
705 this._filmStripView.setFetching(); 741 this._filmStripView.setFetching();
706 } 742 }
707 } 743 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/network/NetworkOverview.js ('k') | Source/devtools/front_end/network/NetworkTimeCalculator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698