| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 virtual ReadResult Get(const std::string& key) OVERRIDE; | 34 virtual ReadResult Get(const std::string& key) OVERRIDE; |
| 35 virtual ReadResult Get(const std::vector<std::string>& keys) OVERRIDE; | 35 virtual ReadResult Get(const std::vector<std::string>& keys) OVERRIDE; |
| 36 virtual ReadResult Get() OVERRIDE; | 36 virtual ReadResult Get() OVERRIDE; |
| 37 virtual WriteResult Set(const std::string& key, const Value& value) OVERRIDE; | 37 virtual WriteResult Set(const std::string& key, const Value& value) OVERRIDE; |
| 38 virtual WriteResult Set(const DictionaryValue& settings) OVERRIDE; | 38 virtual WriteResult Set(const DictionaryValue& settings) OVERRIDE; |
| 39 virtual WriteResult Remove(const std::string& key) OVERRIDE; | 39 virtual WriteResult Remove(const std::string& key) OVERRIDE; |
| 40 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; | 40 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; |
| 41 virtual WriteResult Clear() OVERRIDE; | 41 virtual WriteResult Clear() OVERRIDE; |
| 42 | 42 |
| 43 // Sync-related methods, analogous to those on SyncableService (handled by | 43 // Sync-related methods, analogous to those on SyncableService (handled by |
| 44 // ExtensionSettings). | 44 // ExtensionSettings), but with looser guarantees about when the methods |
| 45 // can be called. |
| 46 |
| 47 // Must only be called if sync isn't already active; not idempotent since |
| 48 // behaviour would be undefined given differerent values of |sync_state|. |
| 45 SyncError StartSyncing( | 49 SyncError StartSyncing( |
| 46 // Either SETTINGS or APP_SETTINGS. | 50 // Either SETTINGS or APP_SETTINGS. |
| 47 syncable::ModelType type, | 51 syncable::ModelType type, |
| 48 const DictionaryValue& sync_state, | 52 const DictionaryValue& sync_state, |
| 49 // Must NOT be NULL. Ownership NOT taken. | 53 // Must NOT be NULL. Ownership NOT taken. |
| 50 SyncChangeProcessor* sync_processor); | 54 SyncChangeProcessor* sync_processor); |
| 55 |
| 56 // May be called at any time (idempotent). |
| 51 void StopSyncing(); | 57 void StopSyncing(); |
| 52 std::vector<SyncError> ProcessSyncChanges( | 58 |
| 53 const SettingSyncDataList& sync_changes); | 59 // May be called at any time; changes will be ignored if sync isn't active. |
| 60 SyncError ProcessSyncChanges(const SettingSyncDataList& sync_changes); |
| 54 | 61 |
| 55 private: | 62 private: |
| 56 // Propagates some changes to sync by sending an ADD/UPDATE/DELETE depending | 63 // Propagates some changes to sync by sending an ADD/UPDATE/DELETE depending |
| 57 // on the change and the current state of sync. | 64 // on the change and the current state of sync. |
| 58 void SendChangesToSync(const SettingChangeList& changes); | 65 void SendChangesToSync(const SettingChangeList& changes); |
| 59 | 66 |
| 60 // Sends all local settings to sync (synced settings assumed to be empty). | 67 // Sends all local settings to sync (synced settings assumed to be empty). |
| 61 SyncError SendLocalSettingsToSync( | 68 SyncError SendLocalSettingsToSync( |
| 62 const DictionaryValue& settings); | 69 const DictionaryValue& settings); |
| 63 | 70 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // Keys of the settings that are currently being synced. Only used to decide | 109 // Keys of the settings that are currently being synced. Only used to decide |
| 103 // whether an ACTION_ADD or ACTION_UPDATE should be sent to sync on a Set(). | 110 // whether an ACTION_ADD or ACTION_UPDATE should be sent to sync on a Set(). |
| 104 std::set<std::string> synced_keys_; | 111 std::set<std::string> synced_keys_; |
| 105 | 112 |
| 106 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); | 113 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); |
| 107 }; | 114 }; |
| 108 | 115 |
| 109 } // namespace extensions | 116 } // namespace extensions |
| 110 | 117 |
| 111 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ | 118 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ |
| OLD | NEW |