| 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_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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 WriteOptions options, const DictionaryValue& values) OVERRIDE; | 46 WriteOptions options, const DictionaryValue& values) OVERRIDE; |
| 47 virtual WriteResult Remove(const std::string& key) OVERRIDE; | 47 virtual WriteResult Remove(const std::string& key) OVERRIDE; |
| 48 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; | 48 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; |
| 49 virtual WriteResult Clear() OVERRIDE; | 49 virtual WriteResult Clear() OVERRIDE; |
| 50 | 50 |
| 51 // Sync-related methods, analogous to those on SyncableService (handled by | 51 // Sync-related methods, analogous to those on SyncableService (handled by |
| 52 // ExtensionSettings), but with looser guarantees about when the methods | 52 // ExtensionSettings), but with looser guarantees about when the methods |
| 53 // can be called. | 53 // can be called. |
| 54 | 54 |
| 55 // Must only be called if sync isn't already active. | 55 // Must only be called if sync isn't already active. |
| 56 SyncError StartSyncing( | 56 csync::SyncError StartSyncing( |
| 57 const DictionaryValue& sync_state, | 57 const DictionaryValue& sync_state, |
| 58 scoped_ptr<SettingsSyncProcessor> sync_processor); | 58 scoped_ptr<SettingsSyncProcessor> sync_processor); |
| 59 | 59 |
| 60 // May be called at any time (idempotent). | 60 // May be called at any time (idempotent). |
| 61 void StopSyncing(); | 61 void StopSyncing(); |
| 62 | 62 |
| 63 // May be called at any time; changes will be ignored if sync isn't active. | 63 // May be called at any time; changes will be ignored if sync isn't active. |
| 64 SyncError ProcessSyncChanges(const SettingSyncDataList& sync_changes); | 64 csync::SyncError ProcessSyncChanges(const SettingSyncDataList& sync_changes); |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // Sends the changes from |result| to sync if it's enabled. | 67 // Sends the changes from |result| to sync if it's enabled. |
| 68 void SyncResultIfEnabled(const ValueStore::WriteResult& result); | 68 void SyncResultIfEnabled(const ValueStore::WriteResult& result); |
| 69 | 69 |
| 70 // Sends all local settings to sync (synced settings assumed to be empty). | 70 // Sends all local settings to sync (synced settings assumed to be empty). |
| 71 SyncError SendLocalSettingsToSync( | 71 csync::SyncError SendLocalSettingsToSync( |
| 72 const DictionaryValue& settings); | 72 const DictionaryValue& settings); |
| 73 | 73 |
| 74 // Overwrites local state with sync state. | 74 // Overwrites local state with sync state. |
| 75 SyncError OverwriteLocalSettingsWithSync( | 75 csync::SyncError OverwriteLocalSettingsWithSync( |
| 76 const DictionaryValue& sync_state, const DictionaryValue& settings); | 76 const DictionaryValue& sync_state, const DictionaryValue& settings); |
| 77 | 77 |
| 78 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s | 78 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s |
| 79 // are taken. | 79 // are taken. |
| 80 SyncError OnSyncAdd( | 80 csync::SyncError OnSyncAdd( |
| 81 const std::string& key, | 81 const std::string& key, |
| 82 Value* new_value, | 82 Value* new_value, |
| 83 ValueStoreChangeList* changes); | 83 ValueStoreChangeList* changes); |
| 84 SyncError OnSyncUpdate( | 84 csync::SyncError OnSyncUpdate( |
| 85 const std::string& key, | 85 const std::string& key, |
| 86 Value* old_value, | 86 Value* old_value, |
| 87 Value* new_value, | 87 Value* new_value, |
| 88 ValueStoreChangeList* changes); | 88 ValueStoreChangeList* changes); |
| 89 SyncError OnSyncDelete( | 89 csync::SyncError OnSyncDelete( |
| 90 const std::string& key, | 90 const std::string& key, |
| 91 Value* old_value, | 91 Value* old_value, |
| 92 ValueStoreChangeList* changes); | 92 ValueStoreChangeList* changes); |
| 93 | 93 |
| 94 // List of observers to settings changes. | 94 // List of observers to settings changes. |
| 95 const scoped_refptr<ObserverListThreadSafe<SettingsObserver> > observers_; | 95 const scoped_refptr<ObserverListThreadSafe<SettingsObserver> > observers_; |
| 96 | 96 |
| 97 // Id of the extension these settings are for. | 97 // Id of the extension these settings are for. |
| 98 std::string const extension_id_; | 98 std::string const extension_id_; |
| 99 | 99 |
| 100 // Storage area to sync. | 100 // Storage area to sync. |
| 101 const scoped_ptr<ValueStore> delegate_; | 101 const scoped_ptr<ValueStore> delegate_; |
| 102 | 102 |
| 103 // Object which sends changes to sync. | 103 // Object which sends changes to sync. |
| 104 scoped_ptr<SettingsSyncProcessor> sync_processor_; | 104 scoped_ptr<SettingsSyncProcessor> sync_processor_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); | 106 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace extensions | 109 } // namespace extensions |
| 110 | 110 |
| 111 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ | 111 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ |
| OLD | NEW |