+ runCleaner();
+ });
+});
+
+chrome.alarms.get(CONSTANTS.CLEANER_ALARM, function(a) {
+ if (a)
+ return;
+
+ chrome.alarms.create(CONSTANTS.CLEANER_ALARM, {
+ // First fire 10 minutes from now.
+ 'when': Date.now() + (10 * 60 * 1000),
+ 'periodInMinutes': 24 * 60
+ });
+});
+
+chrome.alarms.onAlarm.addListener(function(alarm) {
+ chrome.storage.sync.get('autoclear', function(s) {
+ var autoCleaner = s.autoclear || CONSTANTS.NO;
+ if (autoCleaner === CONSTANTS.YES)
+ runCleaner();
+ });