| 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..f351430ec8eed34dad33298b3f02a20c10961150 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"
|
| @@ -61,24 +59,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 +74,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 +94,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 +113,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(
|
|
|