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

Side by Side Diff: lib/client.js

Issue 8402021: Crawler frontend (Closed)
Patch Set: Fixed issues found in review Created Sept. 24, 2012, 2:10 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 | « icon64.png ('k') | lib/crawler.js » ('j') | lib/crawler.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 function get(url, callback)
2 {
3 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
4 .createInstance(Ci.nsIXMLHttpRequest);
5 request.mozBackgroundRequest = true;
6 request.open("GET", url);
7 if (callback)
8 request.addEventListener("load", callback.bind(undefined, request));
9 request.send();
10 }
11
12 function postFile(url, window, filePath, callback)
13 {
14 let formData = new window.FormData;
15 formData.append("file", new window.File(filePath));
Wladimir Palant 2012/09/25 09:40:39 As discussed on IRC: we can avoid using the window
16
17 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
18 .createInstance(Ci.nsIXMLHttpRequest);
19 request.mozBackgroundRequest = true;
20 request.open("POST", url);
21 if (callback)
22 request.addEventListener("load", callback.bind(undefined, request));
23 request.send(formData);
24 }
25
26 let Client = exports.Client = {};
27
28 Client.fetchCrawlableSites = function(backendUrl, callback)
29 {
30 get(backendUrl + "/crawlableSites", function(request)
31 {
32 let sites = request.responseText.trim().split("\n");
33 callback(sites);
34 });
35 };
36
37 Client.sendCrawlerDataFile = function(backendUrl, window, dataFilePath, callback )
38 {
39 postFile(backendUrl + "/crawlerData", window, dataFilePath, callback);
40 };
OLDNEW
« no previous file with comments | « icon64.png ('k') | lib/crawler.js » ('j') | lib/crawler.js » ('J')

Powered by Google App Engine
This is Rietveld