Index: chrome/browser/extensions/extension_settings.h |
diff --git a/chrome/browser/extensions/extension_settings.h b/chrome/browser/extensions/extension_settings.h |
index 1f297daa927266631b4712ab9cf190ae8068edfa..94245241622cf6371fc958d97a00b38242fa049d 100644 |
--- a/chrome/browser/extensions/extension_settings.h |
+++ b/chrome/browser/extensions/extension_settings.h |
@@ -7,19 +7,31 @@ |
#pragma once |
#include "base/callback.h" |
+#include "base/compiler_specific.h" |
#include "base/file_path.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/values.h" |
#include "chrome/browser/extensions/extension_settings_storage.h" |
+#include "chrome/browser/extensions/extension_settings.h" |
+#include "chrome/browser/extensions/extension_settings_storage.h" |
+#include "chrome/browser/extensions/extension_settings_sync_data.h" |
+#include "chrome/browser/extensions/syncable_extension_settings_storage.h" |
+#include "chrome/browser/sync/api/syncable_service.h" |
+#include "chrome/browser/sync/api/sync_data.h" |
+#include "chrome/browser/sync/api/sync_change.h" |
// Manages ExtensionSettingsStorage objects for extensions. |
-class ExtensionSettings : public base::RefCountedThreadSafe<ExtensionSettings> { |
+class ExtensionSettings |
+ : public base::RefCountedThreadSafe<ExtensionSettings>, |
+ public SyncableService { |
public: |
// File path is the base of the extension settings directory. |
// The databases will be at base_path/extension_id. |
explicit ExtensionSettings(const FilePath& base_path); |
// Callback from the GetStorage() methods. |
- typedef base::Callback<void(ExtensionSettingsStorage*)> Callback; |
+ typedef base::Callback<void(SyncableExtensionSettingsStorage*)> Callback; |
// Gets the storage area for a given extension. Only valid for the duration |
// of the callback. |
@@ -40,6 +52,17 @@ class ExtensionSettings : public base::RefCountedThreadSafe<ExtensionSettings> { |
const std::string& extension_id, |
const Callback& callback); |
+ // SyncableService implementation. |
+ virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; |
+ virtual SyncError MergeDataAndStartSyncing( |
+ syncable::ModelType type, |
+ const SyncDataList& initial_sync_data, |
+ SyncChangeProcessor* sync_processor) OVERRIDE; |
+ virtual SyncError ProcessSyncChanges( |
+ const tracked_objects::Location& from_here, |
+ const SyncChangeList& change_list) OVERRIDE; |
+ virtual void StopSyncing(syncable::ModelType type) OVERRIDE; |
+ |
private: |
friend class base::RefCountedThreadSafe<ExtensionSettings>; |
~ExtensionSettings(); |
@@ -50,7 +73,8 @@ class ExtensionSettings : public base::RefCountedThreadSafe<ExtensionSettings> { |
const std::string& extension_id, const Callback& callback); |
// Runs a Callback with a storage argument, then deletes the callback. |
- void RunWithStorage(Callback* callback, ExtensionSettingsStorage* storage); |
+ void RunWithStorage( |
+ Callback* callback, SyncableExtensionSettingsStorage* storage); |
// Starts the process of creation of a storage area. |
// Must be run on the UI thread. |
@@ -72,8 +96,9 @@ class ExtensionSettings : public base::RefCountedThreadSafe<ExtensionSettings> { |
const Callback& callback); |
// Creates a storage area of a given type, optionally wrapped in a cache. |
+ // TODO documentation |
// Returns NULL if creation fails. |
- ExtensionSettingsStorage* CreateStorage( |
+ SyncableExtensionSettingsStorage* CreateStorage( |
const std::string& extension_id, |
ExtensionSettingsStorage::Type type, |
bool cached); |
@@ -82,15 +107,36 @@ class ExtensionSettings : public base::RefCountedThreadSafe<ExtensionSettings> { |
// Must be run on the UI thread. |
void EndCreationOfStorage( |
const std::string& extension_id, |
- ExtensionSettingsStorage* storage, |
+ SyncableExtensionSettingsStorage* storage, |
const Callback& callback); |
+ // Start syncing some extension settings. |
+ void StartSyncingStorage( |
+ const std::string& extension_id, |
+ SyncableExtensionSettingsStorage* storage); |
+ |
+ // Stop syncing some extension settings. |
+ void StopSyncingStorage(ExtensionSettingsStorage* storage); |
+ |
+ // Asserts that there is no sync data for a storage area. |
+ void AssertNoSyncData( |
+ const std::string& extension_id, |
+ SyncableExtensionSettingsStorage* storage); |
+ |
// The base file path to create any leveldb databases at. |
const FilePath base_path_; |
// A cache of ExtensionSettingsStorage objects that have already been created. |
// Ensure that there is only ever one created per extension. |
- std::map<std::string, ExtensionSettingsStorage*> storage_objs_; |
+ std::map<std::string, SyncableExtensionSettingsStorage*> storage_objs_; |
+ |
+ // Sync change processor for sync. |
+ SyncChangeProcessor* sync_processor_; |
+ |
+ // Initial settings received from sync that haven't been merged into their |
+ // respective storage areas. Populated in MergeDataAndStartSyncing and |
+ // depopulated in StartSyncingStorage. |
+ std::map<std::string, DictionaryValue*> unmerged_sync_data_; |
DISALLOW_COPY_AND_ASSIGN(ExtensionSettings); |
}; |