| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SYNC_STORAGE_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_STORAGE_BACKEND_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_STORAGE_BACKEND_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_STORAGE_BACKEND_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <set> | 10 #include <set> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "extensions/browser/api/storage/settings_observer.h" | 18 #include "extensions/browser/api/storage/settings_observer.h" |
| 19 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" | 19 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" |
| 20 #include "extensions/browser/value_store/value_store_factory.h" | 20 #include "extensions/browser/value_store/value_store_factory.h" |
| 21 #include "sync/api/syncable_service.h" | 21 #include "sync/api/syncable_service.h" |
| 22 | 22 |
| 23 namespace syncer { | 23 namespace syncer { |
| 24 class SyncErrorFactory; | 24 class SyncErrorFactory; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace extensions { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 46 ~SyncStorageBackend() override; | 46 ~SyncStorageBackend() override; |
| 47 | 47 |
| 48 virtual ValueStore* GetStorage(const std::string& extension_id); | 48 virtual ValueStore* GetStorage(const std::string& extension_id); |
| 49 virtual void DeleteStorage(const std::string& extension_id); | 49 virtual void DeleteStorage(const std::string& extension_id); |
| 50 | 50 |
| 51 // syncer::SyncableService implementation. | 51 // syncer::SyncableService implementation. |
| 52 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; | 52 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 53 syncer::SyncMergeResult MergeDataAndStartSyncing( | 53 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 54 syncer::ModelType type, | 54 syncer::ModelType type, |
| 55 const syncer::SyncDataList& initial_sync_data, | 55 const syncer::SyncDataList& initial_sync_data, |
| 56 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 56 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 57 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) override; | 57 std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory) override; |
| 58 syncer::SyncError ProcessSyncChanges( | 58 syncer::SyncError ProcessSyncChanges( |
| 59 const tracked_objects::Location& from_here, | 59 const tracked_objects::Location& from_here, |
| 60 const syncer::SyncChangeList& change_list) override; | 60 const syncer::SyncChangeList& change_list) override; |
| 61 void StopSyncing(syncer::ModelType type) override; | 61 void StopSyncing(syncer::ModelType type) override; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 // Gets a weak reference to the storage area for a given extension, | 64 // Gets a weak reference to the storage area for a given extension, |
| 65 // initializing sync with some initial data if sync enabled. | 65 // initializing sync with some initial data if sync enabled. |
| 66 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( | 66 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( |
| 67 const std::string& extension_id, | 67 const std::string& extension_id, |
| 68 scoped_ptr<base::DictionaryValue> sync_data) const; | 68 std::unique_ptr<base::DictionaryValue> sync_data) const; |
| 69 | 69 |
| 70 // Gets all extension IDs known to extension settings. This may not be all | 70 // Gets all extension IDs known to extension settings. This may not be all |
| 71 // installed extensions. | 71 // installed extensions. |
| 72 std::set<std::string> GetKnownExtensionIDs( | 72 std::set<std::string> GetKnownExtensionIDs( |
| 73 ValueStoreFactory::ModelType model_type) const; | 73 ValueStoreFactory::ModelType model_type) const; |
| 74 | 74 |
| 75 // Creates a new SettingsSyncProcessor for an extension. | 75 // Creates a new SettingsSyncProcessor for an extension. |
| 76 scoped_ptr<SettingsSyncProcessor> CreateSettingsSyncProcessor( | 76 std::unique_ptr<SettingsSyncProcessor> CreateSettingsSyncProcessor( |
| 77 const std::string& extension_id) const; | 77 const std::string& extension_id) const; |
| 78 | 78 |
| 79 // The Factory to use for creating new ValueStores. | 79 // The Factory to use for creating new ValueStores. |
| 80 const scoped_refptr<ValueStoreFactory> storage_factory_; | 80 const scoped_refptr<ValueStoreFactory> storage_factory_; |
| 81 | 81 |
| 82 // Quota limits (see SettingsStorageQuotaEnforcer). | 82 // Quota limits (see SettingsStorageQuotaEnforcer). |
| 83 const SettingsStorageQuotaEnforcer::Limits quota_; | 83 const SettingsStorageQuotaEnforcer::Limits quota_; |
| 84 | 84 |
| 85 // The list of observers to settings changes. | 85 // The list of observers to settings changes. |
| 86 const scoped_refptr<SettingsObserverList> observers_; | 86 const scoped_refptr<SettingsObserverList> observers_; |
| 87 | 87 |
| 88 // A cache of ValueStore objects that have already been created. | 88 // A cache of ValueStore objects that have already been created. |
| 89 // Ensure that there is only ever one created per extension. | 89 // Ensure that there is only ever one created per extension. |
| 90 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > | 90 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > |
| 91 StorageObjMap; | 91 StorageObjMap; |
| 92 mutable StorageObjMap storage_objs_; | 92 mutable StorageObjMap storage_objs_; |
| 93 | 93 |
| 94 // Current sync model type. Either EXTENSION_SETTINGS or APP_SETTINGS. | 94 // Current sync model type. Either EXTENSION_SETTINGS or APP_SETTINGS. |
| 95 syncer::ModelType sync_type_; | 95 syncer::ModelType sync_type_; |
| 96 | 96 |
| 97 // Current sync processor, if any. | 97 // Current sync processor, if any. |
| 98 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 98 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_; |
| 99 | 99 |
| 100 // Current sync error handler if any. | 100 // Current sync error handler if any. |
| 101 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; | 101 std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory_; |
| 102 | 102 |
| 103 syncer::SyncableService::StartSyncFlare flare_; | 103 syncer::SyncableService::StartSyncFlare flare_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(SyncStorageBackend); | 105 DISALLOW_COPY_AND_ASSIGN(SyncStorageBackend); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace extensions | 108 } // namespace extensions |
| 109 | 109 |
| 110 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_STORAGE_BACKEND_H_ | 110 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_STORAGE_BACKEND_H_ |
| OLD | NEW |