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: Created Sept. 26, 2012, 8:25 a.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') | no next file with comments »
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, filePath, callback)
13 {
14 let formData = Cc["@mozilla.org/files/formdata;1"]
15 .createInstance(Ci.nsIDOMFormData);
16 formData.append("file", new File(filePath));
17
18 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
19 .createInstance(Ci.nsIXMLHttpRequest);
20 request.mozBackgroundRequest = true;
21 request.open("POST", url);
22 if (callback)
23 request.addEventListener("load", callback.bind(undefined, request));
24 request.send(formData);
25 }
26
27 let Client = exports.Client = {};
28
29 Client.fetchCrawlableSites = function(backendUrl, callback)
30 {
31 get(backendUrl + "/crawlableSites", function(request)
32 {
33 let sites = request.responseText.trim().split("\n");
34 callback(sites);
35 });
36 };
37
38 Client.sendCrawlerDataFile = function(backendUrl, dataFilePath, callback)
39 {
40 postFile(backendUrl + "/crawlerData", dataFilePath, callback);
41 };
OLDNEW
« no previous file with comments | « icon64.png ('k') | lib/crawler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld