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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 296 |
295 EventType = Constants.logEventTypes; | 297 EventType = Constants.logEventTypes; |
296 EventTypeNames = makeInverseMap(EventType); | 298 EventTypeNames = makeInverseMap(EventType); |
297 EventPhase = Constants.logEventPhase; | 299 EventPhase = Constants.logEventPhase; |
298 EventSourceType = Constants.logSourceType; | 300 EventSourceType = Constants.logSourceType; |
299 EventSourceTypeNames = makeInverseMap(EventSourceType); | 301 EventSourceTypeNames = makeInverseMap(EventSourceType); |
300 LogLevelType = Constants.logLevelType; | 302 LogLevelType = Constants.logLevelType; |
301 ClientInfo = Constants.clientInfo; | 303 ClientInfo = Constants.clientInfo; |
302 LoadFlag = Constants.loadFlag; | 304 LoadFlag = Constants.loadFlag; |
303 NetError = Constants.netError; | 305 NetError = Constants.netError; |
| 306 QuicError = Constants.quicError; |
| 307 QuicRstStreamError = Constants.quicRstStreamError; |
304 AddressFamily = Constants.addressFamily; | 308 AddressFamily = Constants.addressFamily; |
305 LoadState = Constants.loadState; | 309 LoadState = Constants.loadState; |
306 | 310 |
307 timeutil.setTimeTickOffset(Constants.timeTickOffset); | 311 timeutil.setTimeTickOffset(Constants.timeTickOffset); |
308 }; | 312 }; |
309 | 313 |
310 /** | 314 /** |
311 * Returns true if it's given a valid-looking constants object. | 315 * Returns true if it's given a valid-looking constants object. |
312 * @param {Object} receivedConstants The received map of constants. | 316 * @param {Object} receivedConstants The received map of constants. |
313 * @return {boolean} True if the |receivedConstants| object appears valid. | 317 * @return {boolean} True if the |receivedConstants| object appears valid. |
314 */ | 318 */ |
315 function areValidConstants(receivedConstants) { | 319 function areValidConstants(receivedConstants) { |
316 return typeof(receivedConstants) == 'object' && | 320 return typeof(receivedConstants) == 'object' && |
317 typeof(receivedConstants.logEventTypes) == 'object' && | 321 typeof(receivedConstants.logEventTypes) == 'object' && |
318 typeof(receivedConstants.clientInfo) == 'object' && | 322 typeof(receivedConstants.clientInfo) == 'object' && |
319 typeof(receivedConstants.logEventPhase) == 'object' && | 323 typeof(receivedConstants.logEventPhase) == 'object' && |
320 typeof(receivedConstants.logSourceType) == 'object' && | 324 typeof(receivedConstants.logSourceType) == 'object' && |
321 typeof(receivedConstants.logLevelType) == 'object' && | 325 typeof(receivedConstants.logLevelType) == 'object' && |
322 typeof(receivedConstants.loadFlag) == 'object' && | 326 typeof(receivedConstants.loadFlag) == 'object' && |
323 typeof(receivedConstants.netError) == 'object' && | 327 typeof(receivedConstants.netError) == 'object' && |
324 typeof(receivedConstants.addressFamily) == 'object' && | 328 typeof(receivedConstants.addressFamily) == 'object' && |
325 typeof(receivedConstants.timeTickOffset) == 'string' && | 329 typeof(receivedConstants.timeTickOffset) == 'string' && |
326 typeof(receivedConstants.logFormatVersion) == 'number'; | 330 typeof(receivedConstants.logFormatVersion) == 'number'; |
327 } | 331 } |
328 | 332 |
329 /** | 333 /** |
330 * Returns the name for netError. | 334 * Returns the name for netError. |
331 * | 335 * |
332 * Example: netErrorToString(-105) would return | 336 * Example: netErrorToString(-105) should return |
333 * "ERR_NAME_NOT_RESOLVED". | 337 * "ERR_NAME_NOT_RESOLVED". |
334 * @param {number} netError The net error code. | 338 * @param {number} netError The net error code. |
335 * @return {string} The name of the given error. | 339 * @return {string} The name of the given error. |
336 */ | 340 */ |
337 function netErrorToString(netError) { | 341 function netErrorToString(netError) { |
338 var str = getKeyWithValue(NetError, netError); | 342 var str = getKeyWithValue(NetError, netError); |
339 if (str == '?') | 343 if (str == '?') |
340 return str; | 344 return str; |
341 return 'ERR_' + str; | 345 return 'ERR_' + str; |
342 } | 346 } |
343 | 347 |
344 /** | 348 /** |
| 349 * Returns the name for quicError. |
| 350 * |
| 351 * Example: quicErrorToString(25) should return |
| 352 * "TIMED_OUT". |
| 353 * @param {number} quicError The QUIC error code. |
| 354 * @return {string} The name of the given error. |
| 355 */ |
| 356 function quicErrorToString(quicError) { |
| 357 return getKeyWithValue(QuicError, quicError); |
| 358 } |
| 359 |
| 360 /** |
| 361 * Returns the name for quicRstStreamError. |
| 362 * |
| 363 * Example: quicRstStreamErrorToString(3) should return |
| 364 * "BAD_APPLICATION_PAYLOAD". |
| 365 * @param {number} quicRstStreamError The QUIC RST_STREAM error code. |
| 366 * @return {string} The name of the given error. |
| 367 */ |
| 368 function quicRstStreamErrorToString(quicRstStreamError) { |
| 369 return getKeyWithValue(QuicRstStreamError, quicRstStreamError); |
| 370 } |
| 371 |
| 372 /** |
345 * Returns a string representation of |family|. | 373 * Returns a string representation of |family|. |
346 * @param {number} family An AddressFamily | 374 * @param {number} family An AddressFamily |
347 * @return {string} A representation of the given family. | 375 * @return {string} A representation of the given family. |
348 */ | 376 */ |
349 function addressFamilyToString(family) { | 377 function addressFamilyToString(family) { |
350 var str = getKeyWithValue(AddressFamily, family); | 378 var str = getKeyWithValue(AddressFamily, family); |
351 // All the address family start with ADDRESS_FAMILY_*. | 379 // All the address family start with ADDRESS_FAMILY_*. |
352 // Strip that prefix since it is redundant and only clutters the output. | 380 // Strip that prefix since it is redundant and only clutters the output. |
353 return str.replace(/^ADDRESS_FAMILY_/, ''); | 381 return str.replace(/^ADDRESS_FAMILY_/, ''); |
354 } | 382 } |
OLD | NEW |