diff options
| author | Stephen Blott | 2014-04-19 11:19:59 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2014-04-19 11:19:59 +0100 | 
| commit | 0ff5b7a8ead8ad9051f0a9ba4a9667f07c9c38ac (patch) | |
| tree | f5fcec5ba2c8384b49a47623a095d0f66a0fc15e /background_scripts/sync.coffee | |
| parent | b8c501ee2e4f85ef8307ec27f39ea98fe0779a6c (diff) | |
| download | vimium-0ff5b7a8ead8ad9051f0a9ba4a9667f07c9c38ac.tar.bz2 | |
Comments for philc.
Diffstat (limited to 'background_scripts/sync.coffee')
| -rw-r--r-- | background_scripts/sync.coffee | 25 | 
1 files changed, 16 insertions, 9 deletions
diff --git a/background_scripts/sync.coffee b/background_scripts/sync.coffee index b1ccb696..dfa260b5 100644 --- a/background_scripts/sync.coffee +++ b/background_scripts/sync.coffee @@ -1,4 +1,3 @@ -  #  # * Sync.set() and Sync.clear() propagate local changes to chrome.storage.sync.  # * Sync.listener() listens for changes to chrome.storage.sync and propagates those @@ -21,6 +20,12 @@  root = exports ? window  root.Sync = Sync = +  # 19/4/14: +  # 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 have 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" ] @@ -34,13 +39,14 @@ root.Sync = Sync =    # Asynchronous fetch from synced storage, called only at startup.    pull: ->      @storage.get null, (items) => +      # Chrome sets chrome.runtime.lastError if there is an error.        if chrome.runtime.lastError is undefined          for own key, value of items            @log "pull: #{key} <- #{value}"            @storeAndPropagate key, value        else -        @log "chrome sync callback for Sync.pull() indicates error" -        @log chrome.runtime.lastError +        console.log "chrome sync callback for Sync.pull() indicates error" +        console.log chrome.runtime.lastError    # Asynchronous message from synced storage.    listener: (changes, area) -> @@ -87,18 +93,20 @@ root.Sync = Sync =      #      if @isSyncKey key        @storage.set @mkKeyValue(key,value), => +        # Chrome sets chrome.runtime.lastError if there is an error.          if chrome.runtime.lastError -          @log "chrome sync callback for Sync.set() indicates error: " + key -          @log chrome.runtime.lastError +          console.log "chrome sync callback for Sync.set() indicates error: " + key +          console.log chrome.runtime.lastError        @log "set scheduled: #{key}=#{value}"    # Only called synchronously from within vimium, never on a callback.    clear: (key) ->      if @isSyncKey key -      @storage.remove key, -> +      @storage.remove key, => +        # Chrome sets chrome.runtime.lastError if there is an error.          if chrome.runtime.lastError -          @log "chrome sync callback for Sync.clear() indicates error: " + key -          @log chrome.runtime.lastError +          console.log "chrome sync callback for Sync.clear() indicates error: " + key +          console.log chrome.runtime.lastError    # Should we synchronize this key?    isSyncKey: (key) -> @@ -129,4 +137,3 @@ root.Sync = Sync =      return true  Sync.register() -  | 
