OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |