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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Tools/GardeningServer/scripts/config.js ('k') | Tools/GardeningServer/scripts/net_unittests.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 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 }; 75 };
76 76
77 net.probe = function(url) 77 net.probe = function(url)
78 { 78 {
79 return net.ajax({ 79 return net.ajax({
80 url: url, 80 url: url,
81 type: 'HEAD', 81 type: 'HEAD',
82 }); 82 });
83 }; 83 };
84 84
85 net._parseJSONP = function(jsonp)
86 {
87 if (!jsonp)
88 return {};
89
90 if (!jsonp.match(/^[^{[]*\(/))
91 return JSON.parse(jsonp);
92
93 var startIndex = jsonp.indexOf('(') + 1;
94 var endIndex = jsonp.lastIndexOf(')');
95 if (startIndex == 0 || endIndex == -1)
96 return {};
97 return JSON.parse(jsonp.substr(startIndex, endIndex - startIndex));
98 };
99
85 // We use XMLHttpRequest and CORS to fetch JSONP rather than using script tags. 100 // We use XMLHttpRequest and CORS to fetch JSONP rather than using script tags.
86 // That's better for security and performance, but we need the server to coopera te 101 // That's better for security and performance, but we need the server to coopera te
87 // by setting CORS headers. 102 // by setting CORS headers.
88 net.jsonp = function(url) 103 net.jsonp = function(url)
89 { 104 {
90 return net.ajax({ 105 return net.ajax({
91 url: url, 106 url: url,
92 }).then(function(jsonp) { 107 }).then(function(jsonp) {
93 return base.parseJSONP(jsonp); 108 return net._parseJSONP(jsonp);
94 }).catch(function(error) { 109 }).catch(function(error) {
95 return {}; 110 return {};
96 }); 111 });
97 }; 112 };
98 113
99 })(); 114 })();
OLDNEW
« 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