| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 logutil = (function() { | 5 logutil = (function() { |
| 6 /** | 6 /** |
| 7 * Creates a new log dump. |events| is a list of all events, |polledData| is | 7 * Creates a new log dump. |events| is a list of all events, |polledData| is |
| 8 * an object containing the results of each poll, |tabData| is an object | 8 * an object containing the results of each poll, |tabData| is an object |
| 9 * containing data for individual tabs, and |date| is the time the dump was | 9 * containing data for individual tabs, and |date| is the time the dump was |
| 10 * created, as a formatted string. | 10 * created, as a formatted string. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 parsedDump = JSON.parse(logFileContents); | 213 parsedDump = JSON.parse(logFileContents); |
| 214 } catch (error) { | 214 } catch (error) { |
| 215 try { | 215 try { |
| 216 // We may have a --log-net-log=blah log dump. If so, remove the comma | 216 // We may have a --log-net-log=blah log dump. If so, remove the comma |
| 217 // after the final good entry, and add the necessary close brackets. | 217 // after the final good entry, and add the necessary close brackets. |
| 218 var end = Math.max(logFileContents.lastIndexOf(',\n'), | 218 var end = Math.max(logFileContents.lastIndexOf(',\n'), |
| 219 logFileContents.lastIndexOf(',\r')); | 219 logFileContents.lastIndexOf(',\r')); |
| 220 if (end != -1) | 220 if (end != -1) |
| 221 parsedDump = JSON.parse(logFileContents.substring(0, end) + ']}'); | 221 parsedDump = JSON.parse(logFileContents.substring(0, end) + ']}'); |
| 222 } | 222 } |
| 223 catch (error) { | 223 catch (error2) { |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 if (!parsedDump) | 227 if (!parsedDump) |
| 228 return 'Unable to parse log dump as JSON file.'; | 228 return 'Unable to parse log dump as JSON file.'; |
| 229 return loadLogDump(parsedDump, fileName); | 229 return loadLogDump(parsedDump, fileName); |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Exports. | 232 // Exports. |
| 233 return { | 233 return { |
| 234 createLogDumpAsync : createLogDumpAsync, | 234 createLogDumpAsync : createLogDumpAsync, |
| 235 loadLogFile : loadLogFile | 235 loadLogFile : loadLogFile |
| 236 }; | 236 }; |
| 237 })(); | 237 })(); |
| OLD | NEW |