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

Side by Side Diff: chromeDevenvPoller__.js

Issue 29333541: Issue 3515 - Use fetch() API instead XMLHttpRequest in chromeDevenvPoller__.js (Closed)
Patch Set: Created Jan. 14, 2016, 5:34 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 (function() 5 (function()
6 { 6 {
7 var version = null; 7 var version = null;
8 function doPoll() 8 function doPoll()
9 { 9 {
10 var request = new XMLHttpRequest(); 10 fetch(chrome.extension.getURL("devenvVersion__"))
11 request.open("GET", chrome.extension.getURL("devenvVersion__")); 11 .then(function(response)
12 request.addEventListener("load", function() 12 {
13 { 13 return response.text();
14 if (version == null) 14 })
15 version = request.responseText; 15 .then(function(text)
16 {
17 if (version == null)
18 version = text;
16 19
17 if (request.responseText != version) 20 if (text != version)
18 chrome.runtime.reload(); 21 chrome.runtime.reload();
19 else 22 else
20 window.setTimeout(doPoll, 5000); 23 window.setTimeout(doPoll, 5000);
21 }, false); 24 });
22 request.send(null);
23 } 25 }
24 26
25 // Delay first poll to prevent reloading again immediately after a reload 27 // Delay first poll to prevent reloading again immediately after a reload
26 doPoll(); 28 doPoll();
27 })(); 29 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld