Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1207)

Unified Diff: chrome/browser/extensions/settings/settings_frontend.h

Issue 10784035: Refactored SettingsFrontend and forwarding of calls to the backends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f26c52d19a78bfeb9af56169cfe557f31a0a3f15 100644
--- a/chrome/browser/extensions/settings/settings_frontend.h
+++ b/chrome/browser/extensions/settings/settings_frontend.h
@@ -5,10 +5,10 @@
#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"
@@ -16,7 +16,7 @@
#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 "chrome/browser/extensions/settings/value_store_cache.h"
#include "sync/api/syncable_service.h"
class Profile;
@@ -30,44 +30,39 @@ namespace extensions {
// GetBackendForSync(), which must be called on the FILE thread.
class SettingsFrontend {
public:
- // Creates with the default factory. Ownership of |profile| not taken.
+ // Creates with the default factory.
static SettingsFrontend* Create(Profile* profile);
// Creates with a specific factory |storage_factory| (presumably for tests).
- // Ownership of |profile| not taken.
static SettingsFrontend* Create(
const scoped_refptr<SettingsStorageFactory>& storage_factory,
- // Owership NOT taken.
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 ValueStoreCache::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, ValueStoreCache*> CacheMap;
+
SettingsFrontend(
const scoped_refptr<SettingsStorageFactory>& storage_factory,
- // Ownership NOT taken.
Profile* profile);
// The quota limit configurations for the local and sync areas, taken out of
@@ -84,18 +79,9 @@ 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 ValueStoreCache. The caches
+ // are owned by this object.
+ CacheMap caches_;
DISALLOW_COPY_AND_ASSIGN(SettingsFrontend);
};
« no previous file with comments | « chrome/browser/extensions/settings/settings_api.cc ('k') | chrome/browser/extensions/settings/settings_frontend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698