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

Unified Diff: chrome/browser/resources/google_now/utility.js

Issue 19822007: Updated Google Now to Check the Geolocation Access Preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@r213016
Patch Set: CR Feedback Created 7 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/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
};
}
+

Powered by Google App Engine
This is Rietveld 408576698