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

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

Issue 9121053: Added net logging to DownloadItem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes to comments. 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 this.description_ = e.params.hostname; 133 this.description_ = e.params.hostname;
134 break; 134 break;
135 case LogSourceType.DOWNLOAD: 135 case LogSourceType.DOWNLOAD:
136 switch (e.type) { 136 switch (e.type) {
137 case LogEventType.DOWNLOAD_FILE_RENAMED: 137 case LogEventType.DOWNLOAD_FILE_RENAMED:
138 this.description_ = e.params.new_filename; 138 this.description_ = e.params.new_filename;
139 break; 139 break;
140 case LogEventType.DOWNLOAD_FILE_OPENED: 140 case LogEventType.DOWNLOAD_FILE_OPENED:
141 this.description_ = e.params.file_name; 141 this.description_ = e.params.file_name;
142 break; 142 break;
143 case LogEventType.DOWNLOAD_ITEM_ACTIVE:
144 this.description_ = e.params.file_name;
145 break;
143 } 146 }
144 break; 147 break;
145 case LogSourceType.FILESTREAM: 148 case LogSourceType.FILESTREAM:
146 this.description_ = e.params.file_name; 149 this.description_ = e.params.file_name;
147 break; 150 break;
148 } 151 }
149 152
150 if (this.description_ == undefined) 153 if (this.description_ == undefined)
151 this.description_ = ''; 154 this.description_ = '';
152 }, 155 },
(...skipping 24 matching lines...) Expand all
177 if (this.entries_[0].source.type == LogSourceType.DOWNLOAD) { 180 if (this.entries_[0].source.type == LogSourceType.DOWNLOAD) {
178 // If any rename occurred, use the last name 181 // If any rename occurred, use the last name
179 e = this.findLastLogEntryStartByType_( 182 e = this.findLastLogEntryStartByType_(
180 LogEventType.DOWNLOAD_FILE_RENAMED); 183 LogEventType.DOWNLOAD_FILE_RENAMED);
181 if (e != undefined) 184 if (e != undefined)
182 return e; 185 return e;
183 // Otherwise, if the file was opened, use that name 186 // Otherwise, if the file was opened, use that name
184 e = this.findLogEntryByType_(LogEventType.DOWNLOAD_FILE_OPENED); 187 e = this.findLogEntryByType_(LogEventType.DOWNLOAD_FILE_OPENED);
185 if (e != undefined) 188 if (e != undefined)
186 return e; 189 return e;
190 // History items are never opened, so use the activation info
191 e = this.findLogEntryByType_(LogEventType.DOWNLOAD_ITEM_ACTIVE);
192 if (e != undefined)
193 return e;
187 } 194 }
188 if (this.entries_.length >= 2) { 195 if (this.entries_.length >= 2) {
189 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || 196 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE ||
190 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || 197 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB ||
191 this.entries_[1].type == LogEventType.UDP_CONNECT) { 198 this.entries_[1].type == LogEventType.UDP_CONNECT) {
192 return this.entries_[1]; 199 return this.entries_[1];
193 } 200 }
194 } 201 }
195 return this.entries_[0]; 202 return this.entries_[0];
196 }, 203 },
197 204
198 /** 205 /**
199 * Returns the first entry with the specified type, or undefined if not 206 * Returns the first entry with the specified type, or undefined if not
200 * found. 207 * found.
201 */ 208 */
202 findLogEntryByType_: function(type) { 209 findLogEntryByType_: function(type) {
203 for (var i = 0; i < this.entries_.length; ++i) { 210 for (var i = 0; i < this.entries_.length; ++i) {
204 if (this.entries_[i].type == type) { 211 if (this.entries_[i].type == type) {
205 return this.entries_[i]; 212 return this.entries_[i];
206 } 213 }
207 } 214 }
208 return undefined; 215 return undefined;
209 }, 216 },
210 217
211 /** 218 /**
212 * Returns the last entry with the specified type, or undefined if not 219 * Returns the beginning of the last entry with the specified type, or
213 * found. 220 * undefined if not found.
214 */ 221 */
215 findLastLogEntryStartByType_: function(type) { 222 findLastLogEntryStartByType_: function(type) {
216 for (var i = this.entries_.length - 1; i >= 0; --i) { 223 for (var i = this.entries_.length - 1; i >= 0; --i) {
217 if (this.entries_[i].type == type) { 224 if (this.entries_[i].type == type) {
218 if (this.entries_[i].phase == LogEventPhase.PHASE_BEGIN) 225 if (this.entries_[i].phase == LogEventPhase.PHASE_BEGIN)
219 return this.entries_[i]; 226 return this.entries_[i];
220 } 227 }
221 } 228 }
222 return undefined; 229 return undefined;
223 }, 230 },
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 * Prints descriptive text about |entries_| to a new node added to the end 289 * Prints descriptive text about |entries_| to a new node added to the end
283 * of |parent|. 290 * of |parent|.
284 */ 291 */
285 printAsText: function(parent) { 292 printAsText: function(parent) {
286 printLogEntriesAsText(this.entries_, parent); 293 printLogEntriesAsText(this.entries_, parent);
287 } 294 }
288 }; 295 };
289 296
290 return SourceEntry; 297 return SourceEntry;
291 })(); 298 })();
OLDNEW
« no previous file with comments | « chrome/browser/net/passive_log_collector.cc ('k') | content/browser/download/download_item_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698