diff options
author | treib <treib@chromium.org> | 2015-07-21 07:51:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-21 14:52:30 +0000 |
commit | c349453205678fda3d6a8a7f1a90a5cec56b8216 (patch) | |
tree | 43d9cfdf707c93150510b818d7b828652b74dbb2 /chrome/browser/extensions/sync_bundle.h | |
parent | 6839695e30402d0ea6324a245a956807aeb5bdb7 (diff) | |
download | chromium_src-c349453205678fda3d6a8a7f1a90a5cec56b8216.zip chromium_src-c349453205678fda3d6a8a7f1a90a5cec56b8216.tar.gz chromium_src-c349453205678fda3d6a8a7f1a90a5cec56b8216.tar.bz2 |
Extension syncing: Introduce a NeedsSync pref
that indicates the extension has local changes that still need to be synced.
It's set when something changes before sync is ready, and cleared once the extension state has been synced.
This should handle all conflicts between sync and local state reasonably well, and as a bonus allows us to get rid of the (weird and not-really-working) PendingEnables class.
BUG=509990
Review URL: https://codereview.chromium.org/1240573012
Cr-Commit-Position: refs/heads/master@{#339651}
Diffstat (limited to 'chrome/browser/extensions/sync_bundle.h')
-rw-r--r-- | chrome/browser/extensions/sync_bundle.h | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/chrome/browser/extensions/sync_bundle.h b/chrome/browser/extensions/sync_bundle.h index 750933f..adebbb1 100644 --- a/chrome/browser/extensions/sync_bundle.h +++ b/chrome/browser/extensions/sync_bundle.h @@ -17,34 +17,23 @@ class ExtensionSyncService; namespace extensions { -class Extension; class ExtensionSyncData; class SyncBundle { public: - explicit SyncBundle(ExtensionSyncService* sync_service); + SyncBundle(); ~SyncBundle(); - void MergeDataAndStartSyncing( - const syncer::SyncDataList& initial_sync_data, - scoped_ptr<syncer::SyncChangeProcessor> sync_processor); + void StartSyncing(scoped_ptr<syncer::SyncChangeProcessor> sync_processor); // Resets this class back to its default values, which will disable all // syncing until StartSyncing is called again. void Reset(); // Has this bundle started syncing yet? - // Returns true if MergeDataAndStartSyncing has been called, false otherwise. + // Returns true if StartSyncing has been called, false otherwise. bool IsSyncing() const; - // Checks if the extension with the given |id| is synced. - bool HasExtensionId(const std::string& id) const; - - // Whether the given extension should be included in the SyncDataList to be - // sent to the server. Returns false if there is pending data that should be - // used instead. - bool ShouldIncludeInLocalSyncDataList(const Extension& extension) const; - // Handles the given list of local SyncDatas. This updates the set of synced // extensions as appropriate, and then pushes the corresponding SyncChanges // to the server. @@ -57,12 +46,15 @@ class SyncBundle { const syncer::SyncData& sync_data); // Pushes any sync changes to |extension| to the server. - void PushSyncAddOrUpdate(const Extension& extension); + void PushSyncAddOrUpdate(const std::string& extension_id, + const syncer::SyncData& sync_data); - // Applies the given SyncChange coming from the server. - void ApplySyncChange(const syncer::SyncChange& sync_change); + // Applies the given sync change coming in from the server. This just updates + // the list of synced extensions. + void ApplySyncData(const ExtensionSyncData& extension_sync_data); - // Checks if the extension with the given |id| is pending to be synced. + // Checks if there is pending sync data for the extension with the given |id| + // that should be sent to the server instead of the local state. bool HasPendingExtensionId(const std::string& id) const; // Adds a pending extension to be synced. @@ -82,16 +74,18 @@ class SyncBundle { void AddSyncedExtension(const std::string& id); void RemoveSyncedExtension(const std::string& id); - - // Changes an extension from being pending to synced. - void MarkPendingExtensionSynced(const std::string& id); - - ExtensionSyncService* sync_service_; // Owns us. + bool HasSyncedExtension(const std::string& id) const; scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; + // Stores the set of extensions we know about. Used to decide if a sync change + // should be ACTION_ADD or ACTION_UPDATE. std::set<std::string> synced_extensions_; + // This stores changes we got from sync that we couldn't apply immediately + // (such as installing a new extension, or an update). We'll send this back + // to the server instead of the local state, to prevent the sync state from + // flipping back and forth until all clients are on the same state. std::map<std::string, ExtensionSyncData> pending_sync_data_; DISALLOW_COPY_AND_ASSIGN(SyncBundle); |