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

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

Issue 1994006: Add the requests dumps to the text summary on chrome://net2#data (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/resources/net_internals/index.html » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 /** 5 /**
6 * This view displays options for importing/exporting the captured data. Its 6 * This view displays options for importing/exporting the captured data. Its
7 * primarily usefulness is to allow users to copy-paste their data in an easy 7 * primarily usefulness is to allow users to copy-paste their data in an easy
8 * to read format for bug reports. 8 * to read format for bug reports.
9 * 9 *
10 * - Has a button to generate a text report. 10 * - Has a button to generate a text report.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 text.push('Time to live for failed resolves (ms): ' + 136 text.push('Time to live for failed resolves (ms): ' +
137 hostResolverCache.ttl_failure_ms); 137 hostResolverCache.ttl_failure_ms);
138 138
139 if (hostResolverCache.entries.length > 0) { 139 if (hostResolverCache.entries.length > 0) {
140 text.push(''); 140 text.push('');
141 this.appendPrettyPrintedTable_(hostResolverCache.entries, text); 141 this.appendPrettyPrintedTable_(hostResolverCache.entries, text);
142 } 142 }
143 143
144 text.push(''); 144 text.push('');
145 text.push('----------------------------------------------'); 145 text.push('----------------------------------------------');
146 text.push(' URL requests'); 146 text.push(' Requests');
147 text.push('----------------------------------------------'); 147 text.push('----------------------------------------------');
148 text.push(''); 148 text.push('');
149 149
150 // TODO(eroman): Output the per-request events. 150 this.appendRequestsPrintedAsText_(text);
151 text.push('TODO');
152 151
153 // Open a new window to display this text. 152 // Open a new window to display this text.
154 this.displayPopupWindow_(text.join('\n')); 153 this.displayPopupWindow_(text.join('\n'));
155 }; 154 };
156 155
156 DataView.prototype.appendRequestsPrintedAsText_ = function(out) {
157 // Concatenate the passively captured events with the actively captured events
158 // into a single array.
159 var allEvents = g_browser.getAllPassivelyCapturedEvents().concat(
160 g_browser.getAllActivelyCapturedEvents());
161
162 // Group the events into buckets by source ID, and buckets by source type.
163 var sourceIds = [];
164 var sourceIdToEventList = {};
165 var sourceTypeToSourceIdList = {}
166
167 for (var i = 0; i < allEvents.length; ++i) {
168 var e = allEvents[i];
169 var eventList = sourceIdToEventList[e.source.id];
170 if (!eventList) {
171 eventList = [];
172 sourceIdToEventList[e.source.id] = eventList;
173
174 // Update sourceIds
175 sourceIds.push(e.source.id);
176
177 // Update the sourceTypeToSourceIdList list.
178 var idList = sourceTypeToSourceIdList[e.source.type];
179 if (!idList) {
180 idList = [];
181 sourceTypeToSourceIdList[e.source.type] = idList;
182 }
183 idList.push(e.source.id);
184 }
185 eventList.push(e);
186 }
187
188
189 // For each source (ordered by when that source was first started).
190 for (var i = 0; i < sourceIds.length; ++i) {
191 var sourceId = sourceIds[i];
192 var eventList = sourceIdToEventList[sourceId];
193 var sourceType = eventList[0].source.type;
194
195 out.push('------------------------------');
196 out.push(getKeyWithValue(LogSourceType, sourceType) +
197 ' (id=' + sourceId + ')');
198 out.push('------------------------------');
199
200 out.push(PrintSourceEntriesAsText(eventList));
201 }
202 };
203
157 /** 204 /**
158 * Helper function to open a new window and display |text| in it. 205 * Helper function to open a new window and display |text| in it.
159 */ 206 */
160 DataView.prototype.displayPopupWindow_ = function(text) { 207 DataView.prototype.displayPopupWindow_ = function(text) {
161 // Note that we use a data:URL because the chrome:// URL scheme doesn't 208 // Note that we use a data:URL because the chrome:// URL scheme doesn't
162 // allow us to mutate any new windows we open. 209 // allow us to mutate any new windows we open.
163 dataUrl = 'data:text/plain,' + encodeURIComponent(text); 210 dataUrl = 'data:text/plain,' + encodeURIComponent(text);
164 window.open(dataUrl, '_blank'); 211 window.open(dataUrl, '_blank');
165 }; 212 };
166 213
(...skipping 18 matching lines...) Expand all
185 for (var i = 0; i < arrayData.length; ++i) { 232 for (var i = 0; i < arrayData.length; ++i) {
186 var e = arrayData[i]; 233 var e = arrayData[i];
187 var eString = '[' + i + ']: '; 234 var eString = '[' + i + ']: ';
188 for (var key in e) { 235 for (var key in e) {
189 eString += key + "=" + e[key] + "; "; 236 eString += key + "=" + e[key] + "; ";
190 } 237 }
191 out.push(eString); 238 out.push(eString);
192 } 239 }
193 }; 240 };
194 241
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/net_internals/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698