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_SETTINGS_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 explicit SettingsBackend( | 31 explicit SettingsBackend( |
32 // Ownership NOT taken. | 32 // Ownership NOT taken. |
33 SettingsStorageFactory* storage_factory, | 33 SettingsStorageFactory* storage_factory, |
34 const FilePath& base_path, | 34 const FilePath& base_path, |
35 const scoped_refptr<SettingsObserverList>& observers); | 35 const scoped_refptr<SettingsObserverList>& observers); |
36 | 36 |
37 virtual ~SettingsBackend(); | 37 virtual ~SettingsBackend(); |
38 | 38 |
39 // Gets a weak reference to the storage area for a given extension. | 39 // Gets a weak reference to the storage area for a given extension. |
40 // Must be run on the FILE thread. | 40 // Must be run on the FILE thread. |
41 // | 41 SettingsStorage* GetStorage(const std::string& extension_id) const; |
42 // By default this will be an SettingsLeveldbStorage, but on | |
43 // failure to create a leveldb instance will fall back to | |
44 // InMemorySettingsStorage. | |
45 SettingsStorage* GetStorage( | |
46 const std::string& extension_id) const; | |
47 | 42 |
48 // Deletes all setting data for an extension. Call on the FILE thread. | 43 // Deletes all setting data for an extension. Call on the FILE thread. |
49 void DeleteStorage(const std::string& extension_id); | 44 void DeleteStorage(const std::string& extension_id); |
50 | 45 |
51 // SyncableService implementation. | 46 // SyncableService implementation. |
52 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; | 47 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; |
53 virtual SyncError MergeDataAndStartSyncing( | 48 virtual SyncError MergeDataAndStartSyncing( |
54 syncable::ModelType type, | 49 syncable::ModelType type, |
55 const SyncDataList& initial_sync_data, | 50 const SyncDataList& initial_sync_data, |
56 SyncChangeProcessor* sync_processor) OVERRIDE; | 51 SyncChangeProcessor* sync_processor) OVERRIDE; |
57 virtual SyncError ProcessSyncChanges( | 52 virtual SyncError ProcessSyncChanges( |
58 const tracked_objects::Location& from_here, | 53 const tracked_objects::Location& from_here, |
59 const SyncChangeList& change_list) OVERRIDE; | 54 const SyncChangeList& change_list) OVERRIDE; |
60 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; | 55 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; |
61 | 56 |
62 private: | 57 private: |
63 // Gets a weak reference to the storage area for a given extension, | 58 // Gets a weak reference to the storage area for a given extension, |
64 // initializing sync with some initial data if sync enabled. | 59 // initializing sync with some initial data if sync enabled. |
65 // | 60 // |
66 // By default this will be of a cached LEVELDB storage, but on failure to | 61 // By default this will be of a cached LEVELDB storage, but on failure to |
67 // create a leveldb instance will fall back to cached NOOP storage. | 62 // create a leveldb instance will fall back to cached NOOP storage. |
68 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( | 63 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( |
69 const std::string& extension_id, const DictionaryValue& sync_data) const; | 64 const std::string& extension_id, const DictionaryValue& sync_data) const; |
70 | 65 |
71 // Gets all extension IDs known to extension settings. This may not be all | 66 // Gets all extension IDs known to extension settings. This may not be all |
72 // installed extensions. | 67 // installed extensions. |
73 std::set<std::string> GetKnownExtensionIDs() const; | 68 std::set<std::string> GetKnownExtensionIDs() const; |
74 | 69 |
| 70 // Disable the syncing of the storage area for |extension_id|. |
| 71 void DisableSyncForExtension(const std::string& extension_id) const; |
| 72 |
75 // The Factory to use for creating leveldb storage areas. Not owned. | 73 // The Factory to use for creating leveldb storage areas. Not owned. |
76 SettingsStorageFactory* const storage_factory_; | 74 SettingsStorageFactory* const storage_factory_; |
77 | 75 |
78 // The base file path to create any leveldb databases at. | 76 // The base file path to create any leveldb databases at. |
79 const FilePath base_path_; | 77 const FilePath base_path_; |
80 | 78 |
81 // The list of observers to settings changes. | 79 // The list of observers to settings changes. |
82 const scoped_refptr<SettingsObserverList> observers_; | 80 const scoped_refptr<SettingsObserverList> observers_; |
83 | 81 |
84 // A cache of SettingsStorage objects that have already been created. | 82 // A cache of SettingsStorage objects that have already been created. |
85 // Ensure that there is only ever one created per extension. | 83 // Ensure that there is only ever one created per extension. |
86 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > | 84 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > |
87 StorageObjMap; | 85 StorageObjMap; |
88 mutable StorageObjMap storage_objs_; | 86 mutable StorageObjMap storage_objs_; |
89 | 87 |
90 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled | 88 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled |
91 // yet, and either SETTINGS or APP_SETTINGS if it has been. | 89 // yet, and either SETTINGS or APP_SETTINGS if it has been. |
92 syncable::ModelType sync_type_; | 90 syncable::ModelType sync_type_; |
93 | 91 |
94 // Current sync processor, if any. | 92 // Current sync processor, if any. |
95 SyncChangeProcessor* sync_processor_; | 93 SyncChangeProcessor* sync_processor_; |
96 | 94 |
97 DISALLOW_COPY_AND_ASSIGN(SettingsBackend); | 95 DISALLOW_COPY_AND_ASSIGN(SettingsBackend); |
98 }; | 96 }; |
99 | 97 |
100 } // namespace extensions | 98 } // namespace extensions |
101 | 99 |
102 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ | 100 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ |
OLD | NEW |