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

Unified Diff: Tools/GardeningServer/scripts/net.js

Issue 400423002: Remove base.* methods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | « Tools/GardeningServer/scripts/config.js ('k') | Tools/GardeningServer/scripts/net_unittests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/GardeningServer/scripts/net.js
diff --git a/Tools/GardeningServer/scripts/net.js b/Tools/GardeningServer/scripts/net.js
index 644457b05bdfc6dd6022354c0a829b1c0e06263e..23baf536ab4c6b8d740ea52e22716436ca5a20e4 100644
--- a/Tools/GardeningServer/scripts/net.js
+++ b/Tools/GardeningServer/scripts/net.js
@@ -82,6 +82,21 @@ net.probe = function(url)
});
};
+net._parseJSONP = function(jsonp)
+{
+ if (!jsonp)
+ return {};
+
+ if (!jsonp.match(/^[^{[]*\(/))
+ return JSON.parse(jsonp);
+
+ var startIndex = jsonp.indexOf('(') + 1;
+ var endIndex = jsonp.lastIndexOf(')');
+ if (startIndex == 0 || endIndex == -1)
+ return {};
+ return JSON.parse(jsonp.substr(startIndex, endIndex - startIndex));
+};
+
// We use XMLHttpRequest and CORS to fetch JSONP rather than using script tags.
// That's better for security and performance, but we need the server to cooperate
// by setting CORS headers.
@@ -90,7 +105,7 @@ net.jsonp = function(url)
return net.ajax({
url: url,
}).then(function(jsonp) {
- return base.parseJSONP(jsonp);
+ return net._parseJSONP(jsonp);
}).catch(function(error) {
return {};
});
« no previous file with comments | « Tools/GardeningServer/scripts/config.js ('k') | Tools/GardeningServer/scripts/net_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698