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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeDevenvPoller__.js
===================================================================
--- a/chromeDevenvPoller__.js
+++ b/chromeDevenvPoller__.js
@@ -7,19 +7,21 @@
var version = null;
function doPoll()
{
- var request = new XMLHttpRequest();
- request.open("GET", chrome.extension.getURL("devenvVersion__"));
- request.addEventListener("load", function()
- {
- if (version == null)
- version = request.responseText;
+ fetch(chrome.extension.getURL("devenvVersion__"))
+ .then(function(response)
+ {
+ return response.text();
+ })
+ .then(function(text)
+ {
+ if (version == null)
+ version = text;
- if (request.responseText != version)
- chrome.runtime.reload();
- else
- window.setTimeout(doPoll, 5000);
- }, false);
- request.send(null);
+ if (text != version)
+ chrome.runtime.reload();
+ else
+ window.setTimeout(doPoll, 5000);
+ });
}
// Delay first poll to prevent reloading again immediately after a reload
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld