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

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: Sync and Resolve Conflicts 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
« no previous file with comments | « chrome/browser/resources/google_now/background_unittest.gtestjs ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7a7585d6b951d20bfdad4675ecb3d21b3b2d98ed..309ee57e0f2daf1c5c30b3c4f013cdb291d15886 100644
--- a/chrome/browser/resources/google_now/utility.js
+++ b/chrome/browser/resources/google_now/utility.js
@@ -130,7 +130,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);
@@ -332,6 +332,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
@@ -388,12 +399,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
};
}
+
« no previous file with comments | « chrome/browser/resources/google_now/background_unittest.gtestjs ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698