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

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

Issue 9223019: Added net logging to BaseFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup Created 8 years, 10 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 // 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 var SourceEntry = (function() { 5 var SourceEntry = (function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * A SourceEntry gathers all log entries with the same source. 9 * A SourceEntry gathers all log entries with the same source.
10 * 10 *
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 parent.getDescription().length > 0) { 125 parent.getDescription().length > 0) {
126 this.description_ += ' [' + parent.getDescription() + ']'; 126 this.description_ += ' [' + parent.getDescription() + ']';
127 } 127 }
128 } 128 }
129 } 129 }
130 break; 130 break;
131 case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST: 131 case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST:
132 case LogSourceType.DNS_TRANSACTION: 132 case LogSourceType.DNS_TRANSACTION:
133 this.description_ = e.params.hostname; 133 this.description_ = e.params.hostname;
134 break; 134 break;
135 case LogSourceType.DOWNLOAD:
136 switch (e.type) {
137 case LogEventType.DOWNLOAD_FILE_RENAMED:
138 this.description_ = e.params.new_filename;
139 break;
140 case LogEventType.DOWNLOAD_FILE_OPENED:
141 this.description_ = e.params.file_name;
142 break;
143 }
144 break;
135 case LogSourceType.FILESTREAM: 145 case LogSourceType.FILESTREAM:
136 this.description_ = e.params.file_name; 146 this.description_ = e.params.file_name;
137 break; 147 break;
138 } 148 }
139 149
140 if (this.description_ == undefined) 150 if (this.description_ == undefined)
141 this.description_ = ''; 151 this.description_ = '';
142 }, 152 },
143 153
144 /** 154 /**
(...skipping 12 matching lines...) Expand all
157 * TYPE_SOCKET_STREAM_CONNECT. 167 * TYPE_SOCKET_STREAM_CONNECT.
158 */ 168 */
159 getStartEntry_: function() { 169 getStartEntry_: function() {
160 if (this.entries_.length < 1) 170 if (this.entries_.length < 1)
161 return undefined; 171 return undefined;
162 if (this.entries_[0].source.type == LogSourceType.FILESTREAM) { 172 if (this.entries_[0].source.type == LogSourceType.FILESTREAM) {
163 var e = this.findLogEntryByType_(LogEventType.FILE_STREAM_OPEN); 173 var e = this.findLogEntryByType_(LogEventType.FILE_STREAM_OPEN);
164 if (e != undefined) 174 if (e != undefined)
165 return e; 175 return e;
166 } 176 }
177 if (this.entries_[0].source.type == LogSourceType.DOWNLOAD) {
178 // If any rename occurred, use the last name
179 e = this.findLastLogEntryByType_(LogEventType.DOWNLOAD_FILE_RENAMED);
180 if (e != undefined)
181 return e;
182 // Otherwise, if the file was opened, use that name
183 e = this.findLogEntryByType_(LogEventType.DOWNLOAD_FILE_OPENED);
184 if (e != undefined)
185 return e;
186 }
167 if (this.entries_.length >= 2) { 187 if (this.entries_.length >= 2) {
168 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || 188 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE ||
169 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || 189 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB ||
170 this.entries_[1].type == LogEventType.UDP_CONNECT) { 190 this.entries_[1].type == LogEventType.UDP_CONNECT) {
171 return this.entries_[1]; 191 return this.entries_[1];
172 } 192 }
173 } 193 }
174 return this.entries_[0]; 194 return this.entries_[0];
175 }, 195 },
176 196
177 /** 197 /**
178 * Returns the first entry with the specified type, or undefined if not 198 * Returns the first entry with the specified type, or undefined if not
179 * found. 199 * found.
180 */ 200 */
181 findLogEntryByType_: function(type) { 201 findLogEntryByType_: function(type) {
182 for (var i = 0; i < this.entries_.length; ++i) { 202 for (var i = 0; i < this.entries_.length; ++i) {
183 if (this.entries_[i].type == type) { 203 if (this.entries_[i].type == type) {
184 return this.entries_[i]; 204 return this.entries_[i];
185 } 205 }
186 } 206 }
187 return undefined; 207 return undefined;
188 }, 208 },
189 209
210 /**
211 * Returns the last entry with the specified type, or undefined if not
212 * found.
213 */
214 findLastLogEntryByType_: function(type) {
215 for (var i = this.entries_.length - 1; i >= 0; --i) {
216 if (this.entries_[i].type == type) {
217 if ((this.entries_[i].phase != LogEventPhase.PHASE_END) &&
218 (this.entries_[i].phase != LogEventPhase.PHASE_FINISH)) {
mmenke1 2012/02/03 18:32:32 Think checking for PHASE_BEGIN makes the most sens
ahendrickson 2012/02/04 05:27:14 Done.
219 return this.entries_[i];
220 }
221 }
222 }
223 return undefined;
224 },
225
190 getLogEntries: function() { 226 getLogEntries: function() {
191 return this.entries_; 227 return this.entries_;
192 }, 228 },
193 229
194 getSourceTypeString: function() { 230 getSourceTypeString: function() {
195 return getKeyWithValue(LogSourceType, this.entries_[0].source.type); 231 return getKeyWithValue(LogSourceType, this.entries_[0].source.type);
196 }, 232 },
197 233
198 getSourceType: function() { 234 getSourceType: function() {
199 return this.entries_[0].source.type; 235 return this.entries_[0].source.type;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 * Prints descriptive text about |entries_| to a new node added to the end 283 * Prints descriptive text about |entries_| to a new node added to the end
248 * of |parent|. 284 * of |parent|.
249 */ 285 */
250 printAsText: function(parent) { 286 printAsText: function(parent) {
251 printLogEntriesAsText(this.entries_, parent); 287 printLogEntriesAsText(this.entries_, parent);
252 } 288 }
253 }; 289 };
254 290
255 return SourceEntry; 291 return SourceEntry;
256 })(); 292 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698