Index: chrome/browser/resources/google_now/utility.js |
diff --git a/chrome/browser/resources/google_now/utility.js b/chrome/browser/resources/google_now/utility.js |
index eb8f5cc0b741c3924fd80dac07c648a57c8f279e..9b2f5915f78122f4df7137e709173f3c37eb49bc 100644 |
--- a/chrome/browser/resources/google_now/utility.js |
+++ b/chrome/browser/resources/google_now/utility.js |
@@ -107,7 +107,7 @@ function buildTaskManager(areConflicting) { |
* task. Otherwise, stores the task for future execution. |
* @param {string} taskName Name of the task. |
* @param {function(function())} task Function to run. Takes a callback |
- * parameter. |
+ * parameter. Call this callback on completion. |
*/ |
function add(taskName, task) { |
console.log('Adding task ' + taskName); |
@@ -291,6 +291,17 @@ function buildAttemptManager( |
} |
/** |
+ * Indicates if this attempt manager has started. |
+ * @param {function(boolean)} callback The function's boolean parameter is |
+ * true if the attempt manager has started, false otherwise. |
+ */ |
+ function isRunning(callback) { |
+ chrome.alarms.get(alarmName, function(alarmInfo) { |
+ callback(!!alarmInfo); |
+ }); |
+ } |
+ |
+ /** |
* Schedules next attempt. |
* @param {number=} opt_previousDelaySeconds Previous delay in a sequence of |
* retry attempts, if specified. Not specified for scheduling first retry |
@@ -348,12 +359,17 @@ function buildAttemptManager( |
chrome.alarms.onAlarm.addListener(function(alarm) { |
if (alarm.name == alarmName) |
- attempt(); |
+ isRunning(function(running) { |
+ if (running) |
+ attempt(); |
+ }); |
}); |
return { |
start: start, |
planForNext: planForNext, |
- stop: stop |
+ stop: stop, |
+ isRunning: isRunning |
}; |
} |
+ |