Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 WriteResult Remove(const std::string& key) override; | 48 WriteResult Remove(const std::string& key) override; |
| 49 WriteResult Remove(const std::vector<std::string>& keys) override; | 49 WriteResult Remove(const std::vector<std::string>& keys) override; |
| 50 WriteResult Clear() override; | 50 WriteResult Clear() override; |
| 51 bool Restore() override; | 51 bool Restore() override; |
| 52 bool RestoreKey(const std::string& key) override; | 52 bool RestoreKey(const std::string& key) override; |
| 53 | 53 |
| 54 // Sync-related methods, analogous to those on SyncableService (handled by | 54 // Sync-related methods, analogous to those on SyncableService (handled by |
| 55 // ExtensionSettings), but with looser guarantees about when the methods | 55 // ExtensionSettings), but with looser guarantees about when the methods |
| 56 // can be called. | 56 // can be called. |
| 57 | 57 |
| 58 // Must only be called if sync isn't already active. | 58 // Starts syncing this storage area. Must only be called if sync isn't |
| 59 // already active. | |
| 60 // |sync_state| is the current state of the extension settings in sync. | |
| 61 // |sync_processor| is used to write out any changes. | |
| 62 // Returns any error when trying to sync, or an empty error on success. | |
| 59 syncer::SyncError StartSyncing( | 63 syncer::SyncError StartSyncing( |
| 60 const base::DictionaryValue& sync_state, | 64 scoped_ptr<base::DictionaryValue> sync_state, |
| 61 scoped_ptr<SettingsSyncProcessor> sync_processor); | 65 scoped_ptr<SettingsSyncProcessor> sync_processor); |
| 62 | 66 |
| 63 // May be called at any time (idempotent). | 67 // Stops syncing this storage area. May be called at any time (idempotent). |
| 64 void StopSyncing(); | 68 void StopSyncing(); |
| 65 | 69 |
| 66 // May be called at any time; changes will be ignored if sync isn't active. | 70 // Pushes a list of sync changes into this storage area. May be called at |
| 67 syncer::SyncError ProcessSyncChanges(const SettingSyncDataList& sync_changes); | 71 // any time, changes will be ignored if sync isn't active. |
| 72 // |sync_changes| are the changes to push. | |
| 73 // Returns any error when trying to sync, or an empty error on success. | |
| 74 syncer::SyncError ProcessSyncChanges( | |
| 75 scoped_ptr<SettingSyncDataList> sync_changes); | |
| 68 | 76 |
| 69 private: | 77 private: |
| 70 // Sends the changes from |result| to sync if it's enabled. | 78 // Sends the changes from |result| to sync if it's enabled. |
| 71 void SyncResultIfEnabled(const ValueStore::WriteResult& result); | 79 void SyncResultIfEnabled(const ValueStore::WriteResult& result); |
| 72 | 80 |
| 73 // Sends all local settings to sync (synced settings assumed to be empty). | 81 // Sends all local settings to sync. This assumes that there are no settings |
| 82 // in sync yet. | |
| 83 // |local_state| the local storage state. | |
|
Devlin
2015/05/15 21:59:08
nitty nit: missing an is, here. That said, I don'
not at google - send to devlin
2015/05/15 23:28:30
well, sometimes comments on parameters are good, r
| |
| 84 // Returns any error when trying to sync, or an empty error on success. | |
| 74 syncer::SyncError SendLocalSettingsToSync( | 85 syncer::SyncError SendLocalSettingsToSync( |
| 75 const base::DictionaryValue& settings); | 86 scoped_ptr<base::DictionaryValue> local_state); |
| 76 | 87 |
| 77 // Overwrites local state with sync state. | 88 // Overwrites local state with sync state. |
| 89 // |local_state| the local storage state. Will be overwritten by |sync_state|. | |
|
Devlin
2015/05/15 21:59:08
nit: Also missing "is"s here (|local_state| _is_..
not at google - send to devlin
2015/05/15 23:28:30
Done.
| |
| 90 // |sync_state| the storage state from sync. Will write over |local_state|. | |
| 91 // Returns any error when trying to sync, or an empty error on success. | |
| 78 syncer::SyncError OverwriteLocalSettingsWithSync( | 92 syncer::SyncError OverwriteLocalSettingsWithSync( |
| 79 const base::DictionaryValue& sync_state, | 93 scoped_ptr<base::DictionaryValue> sync_state, |
| 80 const base::DictionaryValue& settings); | 94 scoped_ptr<base::DictionaryValue> local_state); |
| 81 | 95 |
| 82 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s | 96 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s |
| 83 // are taken. | 97 // are taken. |
| 84 syncer::SyncError OnSyncAdd( | 98 syncer::SyncError OnSyncAdd( |
| 85 const std::string& key, | 99 const std::string& key, |
| 86 base::Value* new_value, | 100 base::Value* new_value, |
| 87 ValueStoreChangeList* changes); | 101 ValueStoreChangeList* changes); |
| 88 syncer::SyncError OnSyncUpdate( | 102 syncer::SyncError OnSyncUpdate( |
| 89 const std::string& key, | 103 const std::string& key, |
| 90 base::Value* old_value, | 104 base::Value* old_value, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 109 | 123 |
| 110 const syncer::ModelType sync_type_; | 124 const syncer::ModelType sync_type_; |
| 111 const syncer::SyncableService::StartSyncFlare flare_; | 125 const syncer::SyncableService::StartSyncFlare flare_; |
| 112 | 126 |
| 113 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); | 127 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); |
| 114 }; | 128 }; |
| 115 | 129 |
| 116 } // namespace extensions | 130 } // namespace extensions |
| 117 | 131 |
| 118 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ | 132 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ |
| OLD | NEW |