Chromium Code Reviews| 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_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_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" |
| 11 #include "base/observer_list_threadsafe.h" | |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/extension_settings_observer.h" | |
| 12 #include "chrome/browser/extensions/extension_settings_storage.h" | 14 #include "chrome/browser/extensions/extension_settings_storage.h" |
| 13 #include "chrome/browser/extensions/extension_setting_sync_data.h" | 15 #include "chrome/browser/extensions/extension_setting_sync_data.h" |
| 14 #include "chrome/browser/sync/api/syncable_service.h" | 16 #include "chrome/browser/sync/api/syncable_service.h" |
| 15 #include "chrome/browser/sync/api/sync_change.h" | 17 #include "chrome/browser/sync/api/sync_change.h" |
| 16 | 18 |
| 17 // Decorates an ExtensionSettingsStorage with sync behaviour. | 19 // Decorates an ExtensionSettingsStorage with sync behaviour. |
| 18 class SyncableExtensionSettingsStorage : public ExtensionSettingsStorage { | 20 class SyncableExtensionSettingsStorage : public ExtensionSettingsStorage { |
| 19 public: | 21 public: |
| 20 explicit SyncableExtensionSettingsStorage( | 22 explicit SyncableExtensionSettingsStorage( |
| 21 std::string extension_id, | 23 const scoped_refptr<ObserverListThreadSafe<ExtensionSettingsObserver> >& |
| 24 observers, | |
| 25 const std::string& extension_id, | |
| 22 // Ownership taken. | 26 // Ownership taken. |
| 23 ExtensionSettingsStorage* delegate); | 27 ExtensionSettingsStorage* delegate); |
| 24 | 28 |
| 25 virtual ~SyncableExtensionSettingsStorage(); | 29 virtual ~SyncableExtensionSettingsStorage(); |
| 26 | 30 |
| 27 // ExtensionSettingsStorage implementation. | 31 // ExtensionSettingsStorage implementation. |
| 28 virtual Result Get(const std::string& key) OVERRIDE; | 32 virtual Result Get(const std::string& key) OVERRIDE; |
| 29 virtual Result Get(const std::vector<std::string>& keys) OVERRIDE; | 33 virtual Result Get(const std::vector<std::string>& keys) OVERRIDE; |
| 30 virtual Result Get() OVERRIDE; | 34 virtual Result Get() OVERRIDE; |
| 31 virtual Result Set(const std::string& key, const Value& value) OVERRIDE; | 35 virtual Result Set(const std::string& key, const Value& value) OVERRIDE; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 55 void SendDeletesToSync(const std::set<std::string>& keys); | 59 void SendDeletesToSync(const std::set<std::string>& keys); |
| 56 | 60 |
| 57 // Sends all local settings to sync (synced settings assumed to be empty). | 61 // Sends all local settings to sync (synced settings assumed to be empty). |
| 58 SyncError SendLocalSettingsToSync( | 62 SyncError SendLocalSettingsToSync( |
| 59 const DictionaryValue& settings); | 63 const DictionaryValue& settings); |
| 60 | 64 |
| 61 // Overwrites local state with sync state. | 65 // Overwrites local state with sync state. |
| 62 SyncError OverwriteLocalSettingsWithSync( | 66 SyncError OverwriteLocalSettingsWithSync( |
| 63 const DictionaryValue& sync_state, const DictionaryValue& settings); | 67 const DictionaryValue& sync_state, const DictionaryValue& settings); |
| 64 | 68 |
| 69 // List of observers to settings changes. | |
| 70 scoped_refptr<ObserverListThreadSafe<ExtensionSettingsObserver> > observers_; | |
|
akalin
2011/10/12 22:26:30
const scoped_refptr
not at google - send to devlin
2011/10/13 06:40:43
Done.
| |
| 71 | |
| 65 // Id of the extension these settings are for. | 72 // Id of the extension these settings are for. |
| 66 std::string const extension_id_; | 73 std::string const extension_id_; |
| 67 | 74 |
| 68 // Storage area to sync. | 75 // Storage area to sync. |
| 69 const scoped_ptr<ExtensionSettingsStorage> delegate_; | 76 const scoped_ptr<ExtensionSettingsStorage> delegate_; |
| 70 | 77 |
| 71 // Sync processor. Non-NULL while sync is enabled (between calls to | 78 // Sync processor. Non-NULL while sync is enabled (between calls to |
| 72 // StartSyncing and StopSyncing). | 79 // StartSyncing and StopSyncing). |
| 73 SyncChangeProcessor* sync_processor_; | 80 SyncChangeProcessor* sync_processor_; |
| 74 | 81 |
| 75 // Keys of the settings that are currently being synced. | 82 // Keys of the settings that are currently being synced. |
| 76 std::set<std::string> synced_keys_; | 83 std::set<std::string> synced_keys_; |
| 77 | 84 |
| 78 DISALLOW_COPY_AND_ASSIGN(SyncableExtensionSettingsStorage); | 85 DISALLOW_COPY_AND_ASSIGN(SyncableExtensionSettingsStorage); |
| 79 }; | 86 }; |
| 80 | 87 |
| 81 #endif // CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ |
| OLD | NEW |