aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-02-02 14:08:24 +0000
committerStephen Blott2015-02-02 14:25:30 +0000
commit5c155d5eab6632fda9b71713e11af299726d5204 (patch)
treee1c7f991840c1f8fbfadcc430914d021fa8ed5f9 /background_scripts
parent71b609e5e23a894a551884f118d3625251c7aad3 (diff)
downloadvimium-5c155d5eab6632fda9b71713e11af299726d5204.tar.bz2
Strip unreachable code post #1413.
The stripped code is all relocated in #1413.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/sync.coffee37
1 files changed, 4 insertions, 33 deletions
diff --git a/background_scripts/sync.coffee b/background_scripts/sync.coffee
index 93430856..f1850438 100644
--- a/background_scripts/sync.coffee
+++ b/background_scripts/sync.coffee
@@ -20,11 +20,6 @@
root = exports ? window
root.Sync = Sync =
- # April 19 2014: Leave logging statements in, but disable debugging. We may need to come back to this, so
- # removing logging now would be premature. However, if users report problems, they are unlikely to notice
- # and make sense of console logs on background pages. So disable it, by default. For genuine errors, we
- # call console.log directly.
- debug: false
storage: chrome.storage.sync
doNotSync: ["settingsVersion", "previousVersion"]
@@ -36,19 +31,13 @@ root.Sync = Sync =
# Asynchronous fetch from synced storage, called only at startup.
fetchAsync: ->
@storage.get null, (items) =>
- # Chrome sets chrome.runtime.lastError if there is an error.
- if chrome.runtime.lastError is undefined
+ unless chrome.runtime.lastError
for own key, value of items
- @log "fetchAsync: #{key} <- #{value}"
@storeAndPropagate key, value
- else
- console.log "callback for Sync.fetchAsync() indicates error"
- console.log chrome.runtime.lastError
# Asynchronous message from synced storage.
handleStorageUpdate: (changes, area) ->
for own key, change of changes
- @log "handleStorageUpdate: #{key} <- #{change.newValue}"
@storeAndPropagate key, change?.newValue
# Only ever called from asynchronous synced-storage callbacks (fetchAsync and handleStorageUpdate).
@@ -61,12 +50,10 @@ root.Sync = Sync =
if value and value != defaultValueJSON
# Key/value has been changed to non-default value at remote instance.
- @log "storeAndPropagate update: #{key}=#{value}"
localStorage[key] = value
Settings.performPostUpdateHook key, JSON.parse(value)
else
# Key has been reset to default value at remote instance.
- @log "storeAndPropagate clear: #{key}"
if key of localStorage
delete localStorage[key]
Settings.performPostUpdateHook key, defaultValue
@@ -75,28 +62,12 @@ root.Sync = Sync =
# No need to propagate updates to the rest of vimium, that's already been done.
set: (key, value) ->
if @shouldSyncKey key
- @log "set scheduled: #{key}=#{value}"
- key_value = {}
- key_value[key] = value
- @storage.set key_value, =>
- # Chrome sets chrome.runtime.lastError if there is an error.
- if chrome.runtime.lastError
- console.log "callback for Sync.set() indicates error: #{key} <- #{value}"
- console.log chrome.runtime.lastError
+ @storage.set key: value
# Only called synchronously from within vimium, never on a callback.
clear: (key) ->
- if @shouldSyncKey key
- @log "clear scheduled: #{key}"
- @storage.remove key, =>
- # Chrome sets chrome.runtime.lastError if there is an error.
- if chrome.runtime.lastError
- console.log "for Sync.clear() indicates error: #{key}"
- console.log chrome.runtime.lastError
+ @storage.remove key if @shouldSyncKey key
# Should we synchronize this key?
- shouldSyncKey: (key) ->
- key not in @doNotSync
+ shouldSyncKey: (key) -> key not in @doNotSync
- log: (msg) ->
- console.log "Sync: #{msg}" if @debug