| 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 {
|
|
|