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

Unified Diff: chrome/common/extensions/docs/examples/extensions/gmail/background.html

Issue 7470036: Prevent Google Mail Checker from scheduling more than one concurrent request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
Index: chrome/common/extensions/docs/examples/extensions/gmail/background.html
diff --git a/chrome/common/extensions/docs/examples/extensions/gmail/background.html b/chrome/common/extensions/docs/examples/extensions/gmail/background.html
index bb24259b1ae4a6019937be25922cd2f15fad5c30..bce2c3fe26b5c5a44b1d7a5d5ff170d0b9e7b306 100644
--- a/chrome/common/extensions/docs/examples/extensions/gmail/background.html
+++ b/chrome/common/extensions/docs/examples/extensions/gmail/background.html
@@ -16,6 +16,7 @@ var requestTimeout = 1000 * 2; // 5 seconds
var rotation = 0;
var unreadCount = -1;
var loadingAnimation = new LoadingAnimation();
+var requestTimerId;
function getGmailUrl() {
var url = "https://mail.google.com/";
@@ -109,13 +110,16 @@ function init() {
}
function scheduleRequest() {
+ if (requestTimerId) {
+ window.clearTimeout(requestTimerId);
+ }
var randomness = Math.random() * 2;
var exponent = Math.pow(2, requestFailureCount);
var multiplier = Math.max(randomness * exponent, 1);
var delay = Math.min(multiplier * pollIntervalMin, pollIntervalMax);
delay = Math.round(delay);
- window.setTimeout(startRequest, delay);
+ requestTimerId = window.setTimeout(startRequest, delay);
}
// ajax stuff
@@ -147,11 +151,13 @@ function getInboxCount(onSuccess, onError) {
onSuccess(count);
}
+ var invokedErrorCallback = false;
function handleError() {
++requestFailureCount;
window.clearTimeout(abortTimerId);
- if (onError)
+ if (onError && !invokedErrorCallback)
onError();
+ invokedErrorCallback = true;
}
try {
« no previous file with comments | « chrome/common/extensions/docs/examples/extensions/gmail.zip ('k') | chrome/common/extensions/docs/samples.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698