Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4171)

Unified Diff: chrome/browser/resources/net_internals/dataview.js

Issue 6995086: Update about:net-internals to use Javascript for loading logs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix variable names in response to comment Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/net_internals/index.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/dataview.js
===================================================================
--- chrome/browser/resources/net_internals/dataview.js (revision 88439)
+++ 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 logFile = loadLogFileElement.files[0];
+ if (logFile) {
+ var fileReader = new FileReader();
+
+ fileReader.onload = this.onLoadLogFile.bind(this);
+ fileReader.onerror = this.onLoadLogFileError.bind(this);
+
+ fileReader.readAsText(logFile);
+ }
+}
+
+/**
+ * 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.
*/
« no previous file with comments | « no previous file | chrome/browser/resources/net_internals/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698