Chromium Code Reviews| Index: chrome/browser/extensions/settings/settings_frontend.h |
| diff --git a/chrome/browser/extensions/settings/settings_frontend.h b/chrome/browser/extensions/settings/settings_frontend.h |
| index c385fd39a4345f8f66de0f1e4b3c27ddb3811e2f..79c681f90294ae064f52bbb9994145e4360a9ddc 100644 |
| --- a/chrome/browser/extensions/settings/settings_frontend.h |
| +++ b/chrome/browser/extensions/settings/settings_frontend.h |
| @@ -5,18 +5,18 @@ |
| #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ |
| #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ |
| +#include <map> |
| #include <string> |
| #include "base/callback.h" |
| -#include "base/compiler_specific.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/observer_list_threadsafe.h" |
| #include "chrome/browser/extensions/settings/settings_namespace.h" |
| +#include "chrome/browser/extensions/settings/settings_namespace_frontend.h" |
| #include "chrome/browser/extensions/settings/settings_observer.h" |
| #include "chrome/browser/extensions/settings/settings_storage_factory.h" |
| #include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" |
| -#include "chrome/browser/value_store/leveldb_value_store.h" |
| #include "sync/api/syncable_service.h" |
| class Profile; |
| @@ -24,6 +24,8 @@ class ValueStore; |
| namespace extensions { |
| +class SettingsStorageFrontend; |
| + |
| // The component of extension settings which runs on the UI thread, as opposed |
| // to SettingsBackend which lives on the FILE thread. |
| // All public methods, must be called on the UI thread, with the exception of |
| @@ -37,34 +39,33 @@ class SettingsFrontend { |
| // Ownership of |profile| not taken. |
| static SettingsFrontend* Create( |
| const scoped_refptr<SettingsStorageFactory>& storage_factory, |
| - // Owership NOT taken. |
| + // Ownership NOT taken. |
|
not at google - send to devlin
2012/07/18 07:46:18
probably an unnecessary comment in the first place
Joao da Silva
2012/07/18 21:40:25
Removed these comments.
|
| Profile* profile); |
| virtual ~SettingsFrontend(); |
| - typedef base::Callback<void(syncer::SyncableService*)> |
| - SyncableServiceCallback; |
| - typedef base::Callback<void(ValueStore*)> StorageCallback; |
| - |
| // Must only be called from the FILE thread. |type| should be either |
| // APP_SETTINGS or EXTENSION_SETTINGS. |
| syncer::SyncableService* GetBackendForSync(syncer::ModelType type) const; |
| - // Runs |callback| on the FILE thread with the storage area for |
| - // |extension_id|. If there is no extension with that ID, the storage area |
| - // will be NULL. |
| + // Runs |callback| with the storage area of the given |settings_namespace| |
| + // for the |extension_id|. If there is no extension with that ID, the storage |
| + // area will be NULL. |
| void RunWithStorage( |
| const std::string& extension_id, |
| settings_namespace::Namespace settings_namespace, |
| - const StorageCallback& callback); |
| + const SettingsNamespaceFrontend::StorageCallback& callback); |
| - // Deletes the settings for an extension (on the FILE thread). |
| + // Deletes the settings for the given |extension_id|. |
| void DeleteStorageSoon(const std::string& extension_id); |
| // Gets the thread-safe observer list. |
| scoped_refptr<SettingsObserverList> GetObservers(); |
| private: |
| + typedef std::map<settings_namespace::Namespace, SettingsNamespaceFrontend*> |
| + FrontendMap; |
| + |
| SettingsFrontend( |
| const scoped_refptr<SettingsStorageFactory>& storage_factory, |
| // Ownership NOT taken. |
| @@ -84,18 +85,13 @@ class SettingsFrontend { |
| // Observer for |profile_|. |
| scoped_ptr<SettingsObserver> profile_observer_; |
| - // Ref-counted container for each SettingsBackend object. There are 4: an |
| - // apps and an extensions Backend for the LOCAL namespace, and likewise for |
| - // the SYNC namespace. They only differ in what directory the database for |
| - // each exists in. |
| - class BackendWrapper; |
| - struct BackendWrappers { |
| - BackendWrappers(); |
| - ~BackendWrappers(); |
| - scoped_refptr<BackendWrapper> app; |
| - scoped_refptr<BackendWrapper> extension; |
| - }; |
| - std::map<settings_namespace::Namespace, BackendWrappers> backends_; |
| + // Maps a known namespace to its corresponding frontend. The frontends are |
| + // owned by this object. |
| + FrontendMap frontends_; |
| + |
| + // Points to the 'sync' namespace frontend using its specific type, so that |
| + // its backends can be retrieved by GetBackendForSync(). |
| + SettingsStorageFrontend* sync_frontend_; |
| DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); |
| }; |