Chromium Code Reviews| Index: chrome/browser/resources/net_internals/dataview.js |
| =================================================================== |
| --- chrome/browser/resources/net_internals/dataview.js (revision 88328) |
| +++ chrome/browser/resources/net_internals/dataview.js (working copy) |
| @@ -53,8 +53,9 @@ |
| this.capturingTextSpan_ = document.getElementById(capturingTextSpanId); |
| this.loggingTextSpan_ = document.getElementById(loggingTextSpanId); |
| - document.getElementById(loadLogFileId).onclick = |
| - g_browser.loadLogFile.bind(g_browser); |
| + var loadLogFileElement = document.getElementById(loadLogFileId); |
| + loadLogFileElement.onchange = |
| + this.logFileChanged.bind(this, loadLogFileElement); |
| this.updateEventCounts_(); |
| this.waitingForUpdate_ = false; |
| @@ -137,6 +138,37 @@ |
| } |
| /** |
| + * Called when a log file is selected. |
| + * |
| + * Gets the log file from the input element and tries to read from it. |
| + */ |
| +DataView.prototype.logFileChanged = function(loadLogFileElement) { |
| + var log_file = loadLogFileElement.files[0]; |
|
eroman
2011/06/08 23:25:25
nit: useCamelCaseForVariableName.
|
| + if (log_file) { |
| + var file_reader = new FileReader(); |
|
eroman
2011/06/08 23:25:25
ditto.
|
| + |
| + file_reader.onload = this.onLoadLogFile.bind(this); |
| + file_reader.onerror = this.onLoadLogFileError.bind(this); |
| + |
| + file_reader.readAsText(log_file); |
| + } |
| +} |
| + |
| +/** |
| + * Displays an error message when unable to read the selected log file. |
| + */ |
| +DataView.prototype.onLoadLogFileError = function(event) { |
| + alert('Error ' + event.target.error.code + '. Unable to load file.'); |
| +} |
| + |
| +/** |
| + * Tries to load the contents of the log file. |
| + */ |
| +DataView.prototype.onLoadLogFile = function(event) { |
| + g_browser.loadedLogFile(event.target.result); |
| +} |
| + |
| +/** |
| * If not already waiting for results from all updates, triggers all |
| * updates and starts waiting for them to complete. |
| */ |