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

Side by Side Diff: chrome/test/data/webui/net_internals/bandwidth_view.js

Issue 473723002: Update data reduction proxy statistics prefs less often on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tooManyWritesPatch
Patch Set: Fixing nits Created 6 years, 3 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 | « chrome/browser/profiles/profile_impl_io_data.cc ('k') | components/components_tests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Include test fixture. 5 // Include test fixture.
6 GEN_INCLUDE(['net_internals_test.js']); 6 GEN_INCLUDE(['net_internals_test.js']);
7 7
8 // Anonymous namespace 8 // Anonymous namespace
9 (function() { 9 (function() {
10 10
(...skipping 24 matching lines...) Expand all
35 /** 35 /**
36 * Switches to the bandwidth tab, loads a page in the background, and waits 36 * Switches to the bandwidth tab, loads a page in the background, and waits
37 * for the arrival of network statistics. 37 * for the arrival of network statistics.
38 * 38 *
39 * @param {string} url URL to be fetched. 39 * @param {string} url URL to be fetched.
40 */ 40 */
41 start: function(url) { 41 start: function(url) {
42 assertEquals('string', typeof url); 42 assertEquals('string', typeof url);
43 this.url_ = url; 43 this.url_ = url;
44 g_browser.addSessionNetworkStatsObserver(this, true); 44 g_browser.addSessionNetworkStatsObserver(this, true);
45 g_browser.addHistoricNetworkStatsObserver(this, true); 45 g_browser.addHistoricNetworkStatsObserver(this, false);
46 NetInternalsTest.switchToView('bandwidth'); 46 NetInternalsTest.switchToView('bandwidth');
47 chrome.send('loadPage', [this.url_]); 47 chrome.send('loadPage', [this.url_]);
48 }, 48 },
49 49
50 /** 50 /**
51 * Returns the float value the specified cell of the bandwidth table. 51 * Returns the float value the specified cell of the bandwidth table.
52 */ 52 */
53 getBandwidthTableCell_: function(row, col) { 53 getBandwidthTableCell_: function(row, col) {
54 return parseFloat(NetInternalsTest.getTbodyText( 54 return parseFloat(NetInternalsTest.getTbodyText(
55 BandwidthView.MAIN_BOX_ID, row, col)); 55 BandwidthView.MAIN_BOX_ID, row, col));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 }, 93 },
94 94
95 /** 95 /**
96 * SessionNetworkStatsObserver function. Sanity checks the received data 96 * SessionNetworkStatsObserver function. Sanity checks the received data
97 * and constructed table. 97 * and constructed table.
98 98
99 * @param {object} networkStats State of the network session. 99 * @param {object} networkStats State of the network session.
100 */ 100 */
101 onSessionNetworkStatsChanged: function(networkStats) { 101 onSessionNetworkStatsChanged: function(networkStats) {
102 if (this.isDone()) 102 if (this.isDone() || this.sessionVerified)
103 return; 103 return;
104 // Wait until the received content length is at least the size of 104 // Wait until the received content length is at least the size of
105 // our test page and favicon. 105 // our test page and favicon.
106 var expectedLength = this.expectedLength_ + this.faviconLength_; 106 var expectedLength = this.expectedLength_ + this.faviconLength_;
107 if (networkStats.session_received_content_length >= expectedLength) { 107 if (networkStats.session_received_content_length >= expectedLength) {
108 expectLE(expectedLength, networkStats.session_original_content_length); 108 expectLE(expectedLength, networkStats.session_original_content_length);
109 // Column 1 contains session information. 109 // Column 1 contains session information.
110 this.validateBandwidthTableColumn_(1, expectedLength, expectedLength); 110 this.validateBandwidthTableColumn_(1, expectedLength, expectedLength);
111 this.sessionVerified = true; 111 this.sessionVerified = true;
112 this.completeIfDone(); 112 this.completeIfDone();
113 } 113 }
114 }, 114 },
115 115
116 /** 116 /**
117 * HistoricNetworkStatsObserver function. Sanity checks the received data 117 * HistoricNetworkStatsObserver function. Sanity checks the received data
118 * and constructed table. 118 * and constructed table.
119 119
120 * @param {object} networkStats State of the network session. 120 * @param {object} networkStats State of the network session.
121 */ 121 */
122 onHistoricNetworkStatsChanged: function(networkStats) { 122 onHistoricNetworkStatsChanged: function(networkStats) {
123 if (this.isDone()) 123 if (this.isDone() || this.historicVerified)
124 return; 124 return;
125 // Wait until the received content length is at least the size of 125 // The received content length should be zero since the historic
126 // our test page and favicon. 126 // information only updates every hour.
127 var expectedLength = this.expectedLength_ + this.faviconLength_; 127 var expectedLength = 0;
128 if (networkStats.historic_received_content_length >= expectedLength) { 128 // Wait until the table has changed, otherwise the columns will be NaN
129 if (!isNaN(this.getBandwidthTableCell_(0, 2))) {
129 expectLE(expectedLength, networkStats.historic_original_content_length); 130 expectLE(expectedLength, networkStats.historic_original_content_length);
130 // Column 2 contains historic information, and it should be the same as 131 // Column 2 contains historic information.
131 // the session information, because previously there was no history.
132 this.validateBandwidthTableColumn_(2, expectedLength, expectedLength); 132 this.validateBandwidthTableColumn_(2, expectedLength, expectedLength);
133 this.historicVerified = true; 133 this.historicVerified = true;
134 this.completeIfDone(); 134 this.completeIfDone();
135 } 135 }
136 } 136 }
137 }; 137 };
138 138
139 /** 139 /**
140 * Loads a page and checks bandwidth statistics. 140 * Loads a page and checks bandwidth statistics.
141 */ 141 */
142 TEST_F('NetInternalsTest', 'netInternalsSessionBandwidthSucceed', function() { 142 TEST_F('NetInternalsTest', 'netInternalsSessionBandwidthSucceed', function() {
143 var taskQueue = new NetInternalsTest.TaskQueue(true); 143 var taskQueue = new NetInternalsTest.TaskQueue(true);
144 taskQueue.addTask( 144 taskQueue.addTask(
145 new NetInternalsTest.GetTestServerURLTask('files/title1.html')); 145 new NetInternalsTest.GetTestServerURLTask('files/title1.html'));
146 // Load a page with a content length of 66 bytes and a 45-byte favicon. 146 // Load a page with a content length of 66 bytes and a 45-byte favicon.
147 taskQueue.addTask(new BandwidthTask(66, 45)); 147 taskQueue.addTask(new BandwidthTask(66, 45));
148 taskQueue.run(); 148 taskQueue.run();
149 }); 149 });
150 150
151 })(); // Anonymous namespace 151 })(); // Anonymous namespace
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.cc ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698