| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 break; | 92 break; |
| 93 case LogSourceType.DISK_CACHE_ENTRY: | 93 case LogSourceType.DISK_CACHE_ENTRY: |
| 94 case LogSourceType.MEMORY_CACHE_ENTRY: | 94 case LogSourceType.MEMORY_CACHE_ENTRY: |
| 95 this.description_ = e.params.key; | 95 this.description_ = e.params.key; |
| 96 break; | 96 break; |
| 97 case LogSourceType.SPDY_SESSION: | 97 case LogSourceType.SPDY_SESSION: |
| 98 if (e.params.host) | 98 if (e.params.host) |
| 99 this.description_ = e.params.host + ' (' + e.params.proxy + ')'; | 99 this.description_ = e.params.host + ' (' + e.params.proxy + ')'; |
| 100 break; | 100 break; |
| 101 case LogSourceType.SOCKET: | 101 case LogSourceType.SOCKET: |
| 102 // Use description of parent source, if any. |
| 102 if (e.params.source_dependency != undefined) { | 103 if (e.params.source_dependency != undefined) { |
| 103 var connectJobId = e.params.source_dependency.id; | 104 var parentId = e.params.source_dependency.id; |
| 104 var connectJob = | 105 this.description_ = |
| 105 g_browser.sourceTracker.getSourceEntry(connectJobId); | 106 g_browser.sourceTracker.getDescription(parentId); |
| 106 if (connectJob) | 107 } |
| 107 this.description_ = connectJob.getDescription(); | 108 break; |
| 109 case LogSourceType.UDP_SOCKET: |
| 110 if (e.params.address != undefined) { |
| 111 this.description_ = e.params.address; |
| 112 // If the parent of |this| is a DNS_TRANSACTION, use |
| 113 // '<DNS Server IP> [<DNS we're resolving>]'. |
| 114 if (this.entries_[0].type == LogEventType.SOCKET_ALIVE && |
| 115 this.entries_[0].params.source_dependency != undefined) { |
| 116 var parentId = this.entries_[0].params.source_dependency.id; |
| 117 var parent = g_browser.sourceTracker.getSourceEntry(parentId); |
| 118 if (parent && |
| 119 parent.getSourceType() == LogSourceType.DNS_TRANSACTION && |
| 120 parent.getDescription().length > 0) { |
| 121 this.description_ += ' [' + parent.getDescription() + ']'; |
| 122 } |
| 123 } |
| 108 } | 124 } |
| 109 break; | 125 break; |
| 110 case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST: | 126 case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST: |
| 111 case LogSourceType.DNS_TRANSACTION: | 127 case LogSourceType.DNS_TRANSACTION: |
| 112 this.description_ = e.params.hostname; | 128 this.description_ = e.params.hostname; |
| 113 break; | 129 break; |
| 114 } | 130 } |
| 115 | 131 |
| 116 if (this.description_ == undefined) | 132 if (this.description_ == undefined) |
| 117 this.description_ = ''; | 133 this.description_ = ''; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 130 * Returns the starting entry for this source. Conceptually this is the | 146 * Returns the starting entry for this source. Conceptually this is the |
| 131 * first entry that was logged to this source. However, we skip over the | 147 * first entry that was logged to this source. However, we skip over the |
| 132 * TYPE_REQUEST_ALIVE entries which wrap TYPE_URL_REQUEST_START_JOB / | 148 * TYPE_REQUEST_ALIVE entries which wrap TYPE_URL_REQUEST_START_JOB / |
| 133 * TYPE_SOCKET_STREAM_CONNECT. | 149 * TYPE_SOCKET_STREAM_CONNECT. |
| 134 */ | 150 */ |
| 135 getStartEntry_: function() { | 151 getStartEntry_: function() { |
| 136 if (this.entries_.length < 1) | 152 if (this.entries_.length < 1) |
| 137 return undefined; | 153 return undefined; |
| 138 if (this.entries_.length >= 2) { | 154 if (this.entries_.length >= 2) { |
| 139 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || | 155 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || |
| 140 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB) | 156 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || |
| 157 this.entries_[1].type == LogEventType.UDP_CONNECT) { |
| 141 return this.entries_[1]; | 158 return this.entries_[1]; |
| 159 } |
| 142 } | 160 } |
| 143 return this.entries_[0]; | 161 return this.entries_[0]; |
| 144 }, | 162 }, |
| 145 | 163 |
| 146 getLogEntries: function() { | 164 getLogEntries: function() { |
| 147 return this.entries_; | 165 return this.entries_; |
| 148 }, | 166 }, |
| 149 | 167 |
| 150 getSourceTypeString: function() { | 168 getSourceTypeString: function() { |
| 151 return getKeyWithValue(LogSourceType, this.entries_[0].source.type); | 169 return getKeyWithValue(LogSourceType, this.entries_[0].source.type); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 return endTime - startTime; | 217 return endTime - startTime; |
| 200 }, | 218 }, |
| 201 | 219 |
| 202 printAsText: function() { | 220 printAsText: function() { |
| 203 return PrintSourceEntriesAsText(this.entries_); | 221 return PrintSourceEntriesAsText(this.entries_); |
| 204 } | 222 } |
| 205 }; | 223 }; |
| 206 | 224 |
| 207 return SourceEntry; | 225 return SourceEntry; |
| 208 })(); | 226 })(); |
| OLD | NEW |