Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/io.js

Issue 11239001: Use XMLHttpRequest constructor in JS modules (Closed)
Patch Set: Created July 25, 2013, 12:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/downloader.js ('k') | lib/objectTabs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 * Reads strings from a file asynchronously, calls listener.process() with 65 * Reads strings from a file asynchronously, calls listener.process() with
66 * each line read and with a null parameter once the read operation is done. 66 * each line read and with a null parameter once the read operation is done.
67 * The callback will be called when the operation is done. 67 * The callback will be called when the operation is done.
68 */ 68 */
69 readFromFile: function(/**nsIFile|nsIURI*/ file, /**Boolean*/ decode, /**Objec t*/ listener, /**Function*/ callback, /**String*/ timeLineID) 69 readFromFile: function(/**nsIFile|nsIURI*/ file, /**Boolean*/ decode, /**Objec t*/ listener, /**Function*/ callback, /**String*/ timeLineID)
70 { 70 {
71 try 71 try
72 { 72 {
73 let buffer = ""; 73 let buffer = "";
74 let uri = file instanceof Ci.nsIFile ? Services.io.newFileURI(file) : file ; 74 let uri = file instanceof Ci.nsIFile ? Services.io.newFileURI(file) : file ;
75 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance (Ci.nsIXMLHttpRequest); 75 let request = new XMLHttpRequest();
76 request.mozBackgroundRequest = true; 76 request.mozBackgroundRequest = true;
77 request.open("GET", uri.spec); 77 request.open("GET", uri.spec);
78 request.responseType = "moz-chunked-text"; 78 request.responseType = "moz-chunked-text";
79 request.overrideMimeType("text/plain" + (decode ? "? charset=utf-8" : "")) ; 79 request.overrideMimeType("text/plain" + (decode ? "? charset=utf-8" : "")) ;
80 80
81 request.addEventListener("progress", function(event) 81 request.addEventListener("progress", function(event)
82 { 82 {
83 if (timeLineID) 83 if (timeLineID)
84 { 84 {
85 TimeLine.asyncStart(timeLineID); 85 TimeLine.asyncStart(timeLineID);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 isFile: exists && file.isFile(), 330 isFile: exists && file.isFile(),
331 lastModified: exists ? file.lastModifiedTime : 0 331 lastModified: exists ? file.lastModifiedTime : 0
332 }); 332 });
333 } 333 }
334 catch(e) 334 catch(e)
335 { 335 {
336 callback(e); 336 callback(e);
337 } 337 }
338 } 338 }
339 } 339 }
OLDNEW
« no previous file with comments | « lib/downloader.js ('k') | lib/objectTabs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld