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 LogEventType = null; | 10 var EventType = null; |
11 var LogEventTypeNames = null; | 11 var EventTypeNames = null; |
12 var LogEventPhase = null; | 12 var EventPhase = null; |
13 var LogSourceType = null; | 13 var EventSourceType = null; |
14 var LogSourceTypeNames = 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 LoadFlag = null; | 18 var LoadFlag = null; |
19 var AddressFamily = null; | 19 var AddressFamily = null; |
20 | 20 |
21 /** | 21 /** |
22 * Dictionary of all constants, used for saving log files. | 22 * Dictionary of all constants, used for saving log files. |
23 */ | 23 */ |
24 var Constants = null; | 24 var Constants = null; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 * Loads all constants from |constants|. On failure, global dictionaries are | 237 * Loads all constants from |constants|. On failure, global dictionaries are |
238 * not modifed. | 238 * not modifed. |
239 * @param {Object} receivedConstants The map of received constants. | 239 * @param {Object} receivedConstants The map of received constants. |
240 */ | 240 */ |
241 ConstantsObserver.prototype.onReceivedConstants = function(receivedConstants) { | 241 ConstantsObserver.prototype.onReceivedConstants = function(receivedConstants) { |
242 if (!areValidConstants(receivedConstants)) | 242 if (!areValidConstants(receivedConstants)) |
243 return; | 243 return; |
244 | 244 |
245 Constants = receivedConstants; | 245 Constants = receivedConstants; |
246 | 246 |
247 LogEventType = Constants.logEventTypes; | 247 EventType = Constants.eventType; |
248 LogEventTypeNames = makeInverseMap(LogEventType); | 248 EventTypeNames = makeInverseMap(EventType); |
249 LogEventPhase = Constants.logEventPhase; | 249 EventPhase = Constants.eventPhase; |
250 LogSourceType = Constants.logSourceType; | 250 EventSourceType = Constants.sourceType; |
mmenke
2012/06/08 00:12:51
This breaks log loading compatibility.
eroman
2012/06/08 00:13:29
Good point. Let me rework that!
| |
251 LogSourceTypeNames = makeInverseMap(LogSourceType); | 251 EventSourceTypeNames = makeInverseMap(EventSourceType); |
252 LogLevelType = Constants.logLevelType; | 252 LogLevelType = Constants.logLevelType; |
253 ClientInfo = Constants.clientInfo; | 253 ClientInfo = Constants.clientInfo; |
254 LoadFlag = Constants.loadFlag; | 254 LoadFlag = Constants.loadFlag; |
255 NetError = Constants.netError; | 255 NetError = Constants.netError; |
256 AddressFamily = Constants.addressFamily; | 256 AddressFamily = Constants.addressFamily; |
257 | 257 |
258 timeutil.setTimeTickOffset(Constants.timeTickOffset); | 258 timeutil.setTimeTickOffset(Constants.timeTickOffset); |
259 }; | 259 }; |
260 | 260 |
261 /** | 261 /** |
262 * Returns true if it's given a valid-looking constants object. | 262 * Returns true if it's given a valid-looking constants object. |
263 * @param {Object} receivedConstants The received map of constants. | 263 * @param {Object} receivedConstants The received map of constants. |
264 * @return {boolean} True if the |receivedConstants| object appears valid. | 264 * @return {boolean} True if the |receivedConstants| object appears valid. |
265 */ | 265 */ |
266 function areValidConstants(receivedConstants) { | 266 function areValidConstants(receivedConstants) { |
267 return typeof(receivedConstants) == 'object' && | 267 return typeof(receivedConstants) == 'object' && |
268 typeof(receivedConstants.logEventTypes) == 'object' && | 268 typeof(receivedConstants.eventType) == 'object' && |
269 typeof(receivedConstants.clientInfo) == 'object' && | 269 typeof(receivedConstants.clientInfo) == 'object' && |
270 typeof(receivedConstants.logEventPhase) == 'object' && | 270 typeof(receivedConstants.eventPhase) == 'object' && |
271 typeof(receivedConstants.logSourceType) == 'object' && | 271 typeof(receivedConstants.sourceType) == 'object' && |
mmenke
2012/06/08 00:12:51
Ditto.
| |
272 typeof(receivedConstants.logLevelType) == 'object' && | 272 typeof(receivedConstants.logLevelType) == 'object' && |
273 typeof(receivedConstants.loadFlag) == 'object' && | 273 typeof(receivedConstants.loadFlag) == 'object' && |
274 typeof(receivedConstants.netError) == 'object' && | 274 typeof(receivedConstants.netError) == 'object' && |
275 typeof(receivedConstants.addressFamily) == 'object' && | 275 typeof(receivedConstants.addressFamily) == 'object' && |
276 typeof(receivedConstants.timeTickOffset) == 'string' && | 276 typeof(receivedConstants.timeTickOffset) == 'string' && |
277 typeof(receivedConstants.logFormatVersion) == 'number'; | 277 typeof(receivedConstants.logFormatVersion) == 'number'; |
278 } | 278 } |
279 | 279 |
280 /** | 280 /** |
281 * Returns the name for netError. | 281 * Returns the name for netError. |
(...skipping 14 matching lines...) Expand all Loading... | |
296 * Returns a string representation of |family|. | 296 * Returns a string representation of |family|. |
297 * @param {number} family An AddressFamily | 297 * @param {number} family An AddressFamily |
298 * @return {string} A representation of the given family. | 298 * @return {string} A representation of the given family. |
299 */ | 299 */ |
300 function addressFamilyToString(family) { | 300 function addressFamilyToString(family) { |
301 var str = getKeyWithValue(AddressFamily, family); | 301 var str = getKeyWithValue(AddressFamily, family); |
302 // All the address family start with ADDRESS_FAMILY_*. | 302 // All the address family start with ADDRESS_FAMILY_*. |
303 // Strip that prefix since it is redundant and only clutters the output. | 303 // Strip that prefix since it is redundant and only clutters the output. |
304 return str.replace(/^ADDRESS_FAMILY_/, ''); | 304 return str.replace(/^ADDRESS_FAMILY_/, ''); |
305 } | 305 } |
OLD | NEW |