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; | |
16 var ClientInfo = null; | 15 var ClientInfo = null; |
17 var NetError = null; | 16 var NetError = null; |
18 var QuicError = null; | 17 var QuicError = null; |
19 var QuicRstStreamError = null; | 18 var QuicRstStreamError = null; |
20 var LoadFlag = null; | 19 var LoadFlag = null; |
21 var CertStatusFlag = null; | 20 var CertStatusFlag = null; |
22 var LoadState = null; | 21 var LoadState = null; |
23 var AddressFamily = null; | 22 var AddressFamily = null; |
24 var SdchProblemCode = null; | 23 var SdchProblemCode = null; |
25 var DataReductionProxyBypassEventType = null; | 24 var DataReductionProxyBypassEventType = null; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 if (!areValidConstants(receivedConstants)) | 292 if (!areValidConstants(receivedConstants)) |
294 return; | 293 return; |
295 | 294 |
296 Constants = receivedConstants; | 295 Constants = receivedConstants; |
297 | 296 |
298 EventType = Constants.logEventTypes; | 297 EventType = Constants.logEventTypes; |
299 EventTypeNames = makeInverseMap(EventType); | 298 EventTypeNames = makeInverseMap(EventType); |
300 EventPhase = Constants.logEventPhase; | 299 EventPhase = Constants.logEventPhase; |
301 EventSourceType = Constants.logSourceType; | 300 EventSourceType = Constants.logSourceType; |
302 EventSourceTypeNames = makeInverseMap(EventSourceType); | 301 EventSourceTypeNames = makeInverseMap(EventSourceType); |
303 LogLevelType = Constants.logLevelType; | |
304 ClientInfo = Constants.clientInfo; | 302 ClientInfo = Constants.clientInfo; |
305 LoadFlag = Constants.loadFlag; | 303 LoadFlag = Constants.loadFlag; |
306 NetError = Constants.netError; | 304 NetError = Constants.netError; |
307 QuicError = Constants.quicError; | 305 QuicError = Constants.quicError; |
308 QuicRstStreamError = Constants.quicRstStreamError; | 306 QuicRstStreamError = Constants.quicRstStreamError; |
309 AddressFamily = Constants.addressFamily; | 307 AddressFamily = Constants.addressFamily; |
310 LoadState = Constants.loadState; | 308 LoadState = Constants.loadState; |
311 SdchProblemCode = Constants.sdchProblemCode; | 309 SdchProblemCode = Constants.sdchProblemCode; |
312 DataReductionProxyBypassEventType = | 310 DataReductionProxyBypassEventType = |
313 Constants.dataReductionProxyBypassEventType; | 311 Constants.dataReductionProxyBypassEventType; |
(...skipping 10 matching lines...) Expand all Loading... |
324 * Returns true if it's given a valid-looking constants object. | 322 * Returns true if it's given a valid-looking constants object. |
325 * @param {Object} receivedConstants The received map of constants. | 323 * @param {Object} receivedConstants The received map of constants. |
326 * @return {boolean} True if the |receivedConstants| object appears valid. | 324 * @return {boolean} True if the |receivedConstants| object appears valid. |
327 */ | 325 */ |
328 function areValidConstants(receivedConstants) { | 326 function areValidConstants(receivedConstants) { |
329 return typeof(receivedConstants) == 'object' && | 327 return typeof(receivedConstants) == 'object' && |
330 typeof(receivedConstants.logEventTypes) == 'object' && | 328 typeof(receivedConstants.logEventTypes) == 'object' && |
331 typeof(receivedConstants.clientInfo) == 'object' && | 329 typeof(receivedConstants.clientInfo) == 'object' && |
332 typeof(receivedConstants.logEventPhase) == 'object' && | 330 typeof(receivedConstants.logEventPhase) == 'object' && |
333 typeof(receivedConstants.logSourceType) == 'object' && | 331 typeof(receivedConstants.logSourceType) == 'object' && |
334 typeof(receivedConstants.logLevelType) == 'object' && | |
335 typeof(receivedConstants.loadFlag) == 'object' && | 332 typeof(receivedConstants.loadFlag) == 'object' && |
336 typeof(receivedConstants.netError) == 'object' && | 333 typeof(receivedConstants.netError) == 'object' && |
337 typeof(receivedConstants.addressFamily) == 'object' && | 334 typeof(receivedConstants.addressFamily) == 'object' && |
338 typeof(receivedConstants.timeTickOffset) == 'string' && | 335 typeof(receivedConstants.timeTickOffset) == 'string' && |
339 typeof(receivedConstants.logFormatVersion) == 'number'; | 336 typeof(receivedConstants.logFormatVersion) == 'number'; |
340 } | 337 } |
341 | 338 |
342 /** | 339 /** |
343 * Returns the name for netError. | 340 * Returns the name for netError. |
344 * | 341 * |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 * Returns the name for sdchProblemCode. | 388 * Returns the name for sdchProblemCode. |
392 * | 389 * |
393 * Example: sdchProblemCodeToString(5) should return | 390 * Example: sdchProblemCodeToString(5) should return |
394 * "DECODE_BODY_ERROR". | 391 * "DECODE_BODY_ERROR". |
395 * @param {number} sdchProblemCode The SDCH problem code. | 392 * @param {number} sdchProblemCode The SDCH problem code. |
396 * @return {string} The name of the given problem code. | 393 * @return {string} The name of the given problem code. |
397 */ | 394 */ |
398 function sdchProblemCodeToString(sdchProblemCode) { | 395 function sdchProblemCodeToString(sdchProblemCode) { |
399 return getKeyWithValue(SdchProblemCode, sdchProblemCode); | 396 return getKeyWithValue(SdchProblemCode, sdchProblemCode); |
400 } | 397 } |
OLD | NEW |