| 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 log_util = (function() { | 5 log_util = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Creates a new log dump. |events| is a list of all events, |polledData| is | 9 * Creates a new log dump. |events| is a list of all events, |polledData| is |
| 10 * an object containing the results of each poll, |tabData| is an object | 10 * an object containing the results of each poll, |tabData| is an object |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 // Not technically client info, but it's used at the same point in the code. | 48 // Not technically client info, but it's used at the same point in the code. |
| 49 if (numericDate && constants.clientInfo) { | 49 if (numericDate && constants.clientInfo) { |
| 50 constants.clientInfo.numericDate = numericDate; | 50 constants.clientInfo.numericDate = numericDate; |
| 51 } | 51 } |
| 52 | 52 |
| 53 return logDump; | 53 return logDump; |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Returns a new log dump created using the polled data and date from the | |
| 58 * |oldLogDump|. The other parts of the log dump come from current | |
| 59 * net-internals state. | |
| 60 */ | |
| 61 function createUpdatedLogDump(userComments, oldLogDump, privacyStripping) { | |
| 62 var numericDate = null; | |
| 63 if (oldLogDump.constants.clientInfo && | |
| 64 oldLogDump.constants.clientInfo.numericDate) { | |
| 65 numericDate = oldLogDump.constants.clientInfo.numericDate; | |
| 66 } | |
| 67 var logDump = createLogDump( | |
| 68 userComments, Constants, | |
| 69 EventsTracker.getInstance().getAllCapturedEvents(), | |
| 70 oldLogDump.polledData, getTabData_(), numericDate, privacyStripping); | |
| 71 return JSON.stringify(logDump); | |
| 72 } | |
| 73 | |
| 74 /** | |
| 75 * Creates a full log dump using |polledData| and the return value of each | 57 * Creates a full log dump using |polledData| and the return value of each |
| 76 * tab's saveState function and passes it to |callback|. | 58 * tab's saveState function and passes it to |callback|. |
| 77 */ | 59 */ |
| 78 function onUpdateAllCompleted( | 60 function onUpdateAllCompleted( |
| 79 userComments, callback, privacyStripping, polledData) { | 61 userComments, callback, privacyStripping, polledData) { |
| 80 var logDump = createLogDump( | 62 var logDump = createLogDump( |
| 81 userComments, Constants, | 63 userComments, Constants, |
| 82 EventsTracker.getInstance().getAllCapturedEvents(), polledData, | 64 EventsTracker.getInstance().getAllCapturedEvents(), polledData, |
| 83 getTabData_(), timeutil.getCurrentTime(), privacyStripping); | 65 getTabData_(), timeutil.getCurrentTime(), privacyStripping); |
| 84 callback(JSON.stringify(logDump)); | 66 callback(JSON.stringify(logDump)); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 265 } |
| 284 } | 266 } |
| 285 | 267 |
| 286 if (!parsedDump) | 268 if (!parsedDump) |
| 287 return 'Unable to parse log dump as JSON file.'; | 269 return 'Unable to parse log dump as JSON file.'; |
| 288 return errorString + loadLogDump(parsedDump, fileName); | 270 return errorString + loadLogDump(parsedDump, fileName); |
| 289 } | 271 } |
| 290 | 272 |
| 291 // Exports. | 273 // Exports. |
| 292 return { | 274 return { |
| 293 createUpdatedLogDump: createUpdatedLogDump, | |
| 294 createLogDumpAsync: createLogDumpAsync, | 275 createLogDumpAsync: createLogDumpAsync, |
| 295 loadLogFile: loadLogFile | 276 loadLogFile: loadLogFile |
| 296 }; | 277 }; |
| 297 })(); | 278 })(); |
| OLD | NEW |