OLD | NEW |
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 /** | 5 /** |
6 * Dictionary of constants (Initialized soon after loading by data from browser, | 6 * Dictionary of constants (Initialized soon after loading by data from browser, |
7 * updated on load log). The *Types dictionaries map strings to numeric IDs, | 7 * updated on load log). The *Types dictionaries map strings to numeric IDs, |
8 * while the *TypeNames are the other way around. | 8 * while the *TypeNames are the other way around. |
9 */ | 9 */ |
10 var EventType = null; | 10 var EventType = null; |
11 var EventTypeNames = null; | 11 var EventTypeNames = null; |
12 var EventPhase = null; | 12 var EventPhase = null; |
13 var EventSourceType = null; | 13 var EventSourceType = null; |
14 var EventSourceTypeNames = null; | 14 var EventSourceTypeNames = null; |
15 var LogLevelType = null; | 15 var LogLevelType = null; |
16 var ClientInfo = null; | 16 var ClientInfo = null; |
17 var NetError = null; | 17 var NetError = null; |
| 18 var QuicError = null; |
| 19 var QuicRstStreamError = null; |
18 var LoadFlag = null; | 20 var LoadFlag = null; |
19 var LoadState = null; | 21 var LoadState = null; |
20 var AddressFamily = null; | 22 var AddressFamily = null; |
21 | 23 |
22 /** | 24 /** |
23 * Dictionary of all constants, used for saving log files. | 25 * Dictionary of all constants, used for saving log files. |
24 */ | 26 */ |
25 var Constants = null; | 27 var Constants = null; |
26 | 28 |
27 /** | 29 /** |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 298 |
297 EventType = Constants.logEventTypes; | 299 EventType = Constants.logEventTypes; |
298 EventTypeNames = makeInverseMap(EventType); | 300 EventTypeNames = makeInverseMap(EventType); |
299 EventPhase = Constants.logEventPhase; | 301 EventPhase = Constants.logEventPhase; |
300 EventSourceType = Constants.logSourceType; | 302 EventSourceType = Constants.logSourceType; |
301 EventSourceTypeNames = makeInverseMap(EventSourceType); | 303 EventSourceTypeNames = makeInverseMap(EventSourceType); |
302 LogLevelType = Constants.logLevelType; | 304 LogLevelType = Constants.logLevelType; |
303 ClientInfo = Constants.clientInfo; | 305 ClientInfo = Constants.clientInfo; |
304 LoadFlag = Constants.loadFlag; | 306 LoadFlag = Constants.loadFlag; |
305 NetError = Constants.netError; | 307 NetError = Constants.netError; |
| 308 QuicError = Constants.quicError; |
| 309 QuicRstStreamError = Constants.quicRstStreamError; |
306 AddressFamily = Constants.addressFamily; | 310 AddressFamily = Constants.addressFamily; |
307 LoadState = Constants.loadState; | 311 LoadState = Constants.loadState; |
308 | 312 |
309 timeutil.setTimeTickOffset(Constants.timeTickOffset); | 313 timeutil.setTimeTickOffset(Constants.timeTickOffset); |
310 }; | 314 }; |
311 | 315 |
312 /** | 316 /** |
313 * Returns true if it's given a valid-looking constants object. | 317 * Returns true if it's given a valid-looking constants object. |
314 * @param {Object} receivedConstants The received map of constants. | 318 * @param {Object} receivedConstants The received map of constants. |
315 * @return {boolean} True if the |receivedConstants| object appears valid. | 319 * @return {boolean} True if the |receivedConstants| object appears valid. |
316 */ | 320 */ |
317 function areValidConstants(receivedConstants) { | 321 function areValidConstants(receivedConstants) { |
318 return typeof(receivedConstants) == 'object' && | 322 return typeof(receivedConstants) == 'object' && |
319 typeof(receivedConstants.logEventTypes) == 'object' && | 323 typeof(receivedConstants.logEventTypes) == 'object' && |
320 typeof(receivedConstants.clientInfo) == 'object' && | 324 typeof(receivedConstants.clientInfo) == 'object' && |
321 typeof(receivedConstants.logEventPhase) == 'object' && | 325 typeof(receivedConstants.logEventPhase) == 'object' && |
322 typeof(receivedConstants.logSourceType) == 'object' && | 326 typeof(receivedConstants.logSourceType) == 'object' && |
323 typeof(receivedConstants.logLevelType) == 'object' && | 327 typeof(receivedConstants.logLevelType) == 'object' && |
324 typeof(receivedConstants.loadFlag) == 'object' && | 328 typeof(receivedConstants.loadFlag) == 'object' && |
325 typeof(receivedConstants.netError) == 'object' && | 329 typeof(receivedConstants.netError) == 'object' && |
326 typeof(receivedConstants.addressFamily) == 'object' && | 330 typeof(receivedConstants.addressFamily) == 'object' && |
327 typeof(receivedConstants.timeTickOffset) == 'string' && | 331 typeof(receivedConstants.timeTickOffset) == 'string' && |
328 typeof(receivedConstants.logFormatVersion) == 'number'; | 332 typeof(receivedConstants.logFormatVersion) == 'number'; |
329 } | 333 } |
330 | 334 |
331 /** | 335 /** |
332 * Returns the name for netError. | 336 * Returns the name for netError. |
333 * | 337 * |
334 * Example: netErrorToString(-105) would return | 338 * Example: netErrorToString(-105) should return |
335 * "ERR_NAME_NOT_RESOLVED". | 339 * "ERR_NAME_NOT_RESOLVED". |
336 * @param {number} netError The net error code. | 340 * @param {number} netError The net error code. |
337 * @return {string} The name of the given error. | 341 * @return {string} The name of the given error. |
338 */ | 342 */ |
339 function netErrorToString(netError) { | 343 function netErrorToString(netError) { |
340 var str = getKeyWithValue(NetError, netError); | 344 var str = getKeyWithValue(NetError, netError); |
341 if (str == '?') | 345 if (str == '?') |
342 return str; | 346 return str; |
343 return 'ERR_' + str; | 347 return 'ERR_' + str; |
344 } | 348 } |
345 | 349 |
346 /** | 350 /** |
| 351 * Returns the name for quicError. |
| 352 * |
| 353 * Example: quicErrorToString(25) should return |
| 354 * "TIMED_OUT". |
| 355 * @param {number} quicError The QUIC error code. |
| 356 * @return {string} The name of the given error. |
| 357 */ |
| 358 function quicErrorToString(quicError) { |
| 359 return getKeyWithValue(QuicError, quicError); |
| 360 } |
| 361 |
| 362 /** |
| 363 * Returns the name for quicRstStreamError. |
| 364 * |
| 365 * Example: quicRstStreamErrorToString(3) should return |
| 366 * "BAD_APPLICATION_PAYLOAD". |
| 367 * @param {number} quicRstStreamError The QUIC RST_STREAM error code. |
| 368 * @return {string} The name of the given error. |
| 369 */ |
| 370 function quicRstStreamErrorToString(quicRstStreamError) { |
| 371 return getKeyWithValue(QuicRstStreamError, quicRstStreamError); |
| 372 } |
| 373 |
| 374 /** |
347 * Returns a string representation of |family|. | 375 * Returns a string representation of |family|. |
348 * @param {number} family An AddressFamily | 376 * @param {number} family An AddressFamily |
349 * @return {string} A representation of the given family. | 377 * @return {string} A representation of the given family. |
350 */ | 378 */ |
351 function addressFamilyToString(family) { | 379 function addressFamilyToString(family) { |
352 var str = getKeyWithValue(AddressFamily, family); | 380 var str = getKeyWithValue(AddressFamily, family); |
353 // All the address family start with ADDRESS_FAMILY_*. | 381 // All the address family start with ADDRESS_FAMILY_*. |
354 // Strip that prefix since it is redundant and only clutters the output. | 382 // Strip that prefix since it is redundant and only clutters the output. |
355 return str.replace(/^ADDRESS_FAMILY_/, ''); | 383 return str.replace(/^ADDRESS_FAMILY_/, ''); |
356 } | 384 } |
OLD | NEW |