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

Unified Diff: chrome/browser/extensions/api/storage/settings_frontend.cc

Issue 184043031: Split up extensions storage API implementations for sync and local storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (split_sync) Created 6 years, 9 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/api/storage/settings_frontend.cc
diff --git a/chrome/browser/extensions/api/storage/settings_frontend.cc b/chrome/browser/extensions/api/storage/settings_frontend.cc
index f2252ed8207c6624ec7c0e64f8c411ac743282a6..316c1458cd7f45679747b570db022eebaf37bf7a 100644
--- a/chrome/browser/extensions/api/storage/settings_frontend.cc
+++ b/chrome/browser/extensions/api/storage/settings_frontend.cc
@@ -4,15 +4,13 @@
#include "chrome/browser/extensions/api/storage/settings_frontend.h"
-#include <limits>
-
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
#include "base/lazy_instance.h"
#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h"
-#include "chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.h"
+#include "chrome/browser/extensions/api/storage/local_value_store_cache.h"
#include "chrome/common/extensions/api/storage.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -26,8 +24,6 @@ using content::BrowserThread;
namespace extensions {
-namespace storage = api::storage;
-
namespace {
base::LazyInstance<BrowserContextKeyedAPIFactory<SettingsFrontend> > g_factory =
@@ -52,7 +48,7 @@ class DefaultObserver : public SettingsObserver {
args->Append(new base::StringValue(settings_namespace::ToString(
settings_namespace)));
scoped_ptr<Event> event(new Event(
- storage::OnChanged::kEventName, args.Pass()));
+ api::storage::OnChanged::kEventName, args.Pass()));
ExtensionSystem::Get(browser_context_)->event_router()->
DispatchEventToExtension(extension_id, event.Pass());
}
@@ -61,24 +57,6 @@ class DefaultObserver : public SettingsObserver {
BrowserContext* const browser_context_;
};
-SettingsStorageQuotaEnforcer::Limits GetLocalLimits() {
- SettingsStorageQuotaEnforcer::Limits limits = {
- static_cast<size_t>(api::storage::local::QUOTA_BYTES),
- std::numeric_limits<size_t>::max(),
- std::numeric_limits<size_t>::max()
- };
- return limits;
-}
-
-SettingsStorageQuotaEnforcer::Limits GetSyncLimits() {
- SettingsStorageQuotaEnforcer::Limits limits = {
- static_cast<size_t>(api::storage::sync::QUOTA_BYTES),
- static_cast<size_t>(api::storage::sync::QUOTA_BYTES_PER_ITEM),
- static_cast<size_t>(api::storage::sync::MAX_ITEMS)
- };
- return limits;
-}
-
} // namespace
// static
@@ -94,18 +72,14 @@ SettingsFrontend* SettingsFrontend::CreateForTesting(
}
SettingsFrontend::SettingsFrontend(BrowserContext* context)
- : local_quota_limit_(GetLocalLimits()),
- sync_quota_limit_(GetSyncLimits()),
- browser_context_(context) {
+ : browser_context_(context) {
Init(new LeveldbSettingsStorageFactory());
}
SettingsFrontend::SettingsFrontend(
const scoped_refptr<SettingsStorageFactory>& factory,
BrowserContext* context)
- : local_quota_limit_(GetLocalLimits()),
- sync_quota_limit_(GetSyncLimits()),
- browser_context_(context) {
+ : browser_context_(context) {
Init(factory);
}
@@ -118,24 +92,11 @@ void SettingsFrontend::Init(
observers_->AddObserver(browser_context_observer_.get());
- const base::FilePath& browser_context_path = browser_context_->GetPath();
caches_[settings_namespace::LOCAL] =
- new SyncOrLocalValueStoreCache(
- settings_namespace::LOCAL,
- factory,
- local_quota_limit_,
- observers_,
- browser_context_path);
- caches_[settings_namespace::SYNC] =
- new SyncOrLocalValueStoreCache(
- settings_namespace::SYNC,
- factory,
- sync_quota_limit_,
- observers_,
- browser_context_path);
-
- // Add any additional caches the embedder supports (for example, a cache
- // for chrome.storage.managed).
+ new LocalValueStoreCache(factory, browser_context_->GetPath());
+
+ // Add any additional caches the embedder supports (for example, caches
+ // for chrome.storage.managed and chrome.storage.sync).
ExtensionsAPIClient::Get()->AddAdditionalValueStoreCaches(
browser_context_, factory, observers_, &caches_);
}
@@ -150,15 +111,12 @@ SettingsFrontend::~SettingsFrontend() {
}
}
-syncer::SyncableService* SettingsFrontend::GetBackendForSync(
- syncer::ModelType type) const {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- CacheMap::const_iterator it = caches_.find(settings_namespace::SYNC);
- DCHECK(it != caches_.end());
- const SyncOrLocalValueStoreCache* sync_cache =
- static_cast<const SyncOrLocalValueStoreCache*>(it->second);
- DCHECK(type == syncer::APP_SETTINGS || type == syncer::EXTENSION_SETTINGS);
- return sync_cache->GetSyncableService(type);
+ValueStoreCache* SettingsFrontend::GetValueStoreCache(
+ settings_namespace::Namespace settings_namespace) const {
+ CacheMap::const_iterator it = caches_.find(settings_namespace);
+ if (it != caches_.end())
+ return it->second;
+ return NULL;
}
bool SettingsFrontend::IsStorageEnabled(

Powered by Google App Engine
This is Rietveld 408576698