| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 5 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 using content::BrowserContext; | 28 using content::BrowserContext; |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 | 30 |
| 31 namespace extensions { | 31 namespace extensions { |
| 32 | 32 |
| 33 namespace storage = api::storage; | 33 namespace storage = api::storage; |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 base::LazyInstance<ProfileKeyedAPIFactory<SettingsFrontend> > g_factory = | 37 base::LazyInstance<BrowserContextKeyedAPIFactory<SettingsFrontend> > g_factory = |
| 38 LAZY_INSTANCE_INITIALIZER; | 38 LAZY_INSTANCE_INITIALIZER; |
| 39 | 39 |
| 40 // Settings change Observer which forwards changes on to the extension | 40 // Settings change Observer which forwards changes on to the extension |
| 41 // processes for |context| and its incognito partner if it exists. | 41 // processes for |context| and its incognito partner if it exists. |
| 42 class DefaultObserver : public SettingsObserver { | 42 class DefaultObserver : public SettingsObserver { |
| 43 public: | 43 public: |
| 44 explicit DefaultObserver(BrowserContext* context) | 44 explicit DefaultObserver(BrowserContext* context) |
| 45 : browser_context_(context) {} | 45 : browser_context_(context) {} |
| 46 | 46 |
| 47 // SettingsObserver implementation. | 47 // SettingsObserver implementation. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 static_cast<size_t>(api::storage::sync::QUOTA_BYTES_PER_ITEM), | 80 static_cast<size_t>(api::storage::sync::QUOTA_BYTES_PER_ITEM), |
| 81 static_cast<size_t>(api::storage::sync::MAX_ITEMS) | 81 static_cast<size_t>(api::storage::sync::MAX_ITEMS) |
| 82 }; | 82 }; |
| 83 return limits; | 83 return limits; |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace | 86 } // namespace |
| 87 | 87 |
| 88 // static | 88 // static |
| 89 SettingsFrontend* SettingsFrontend::Get(BrowserContext* context) { | 89 SettingsFrontend* SettingsFrontend::Get(BrowserContext* context) { |
| 90 return ProfileKeyedAPIFactory<SettingsFrontend>::GetForProfile(context); | 90 return BrowserContextKeyedAPIFactory<SettingsFrontend>::Get(context); |
| 91 } | 91 } |
| 92 | 92 |
| 93 // static | 93 // static |
| 94 SettingsFrontend* SettingsFrontend::CreateForTesting( | 94 SettingsFrontend* SettingsFrontend::CreateForTesting( |
| 95 const scoped_refptr<SettingsStorageFactory>& storage_factory, | 95 const scoped_refptr<SettingsStorageFactory>& storage_factory, |
| 96 BrowserContext* context) { | 96 BrowserContext* context) { |
| 97 return new SettingsFrontend(storage_factory, context); | 97 return new SettingsFrontend(storage_factory, context); |
| 98 } | 98 } |
| 99 | 99 |
| 100 SettingsFrontend::SettingsFrontend(BrowserContext* context) | 100 SettingsFrontend::SettingsFrontend(BrowserContext* context) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 settings_namespace::Namespace settings_namespace) { | 211 settings_namespace::Namespace settings_namespace) { |
| 212 CacheMap::iterator it = caches_.find(settings_namespace); | 212 CacheMap::iterator it = caches_.find(settings_namespace); |
| 213 if (it != caches_.end()) { | 213 if (it != caches_.end()) { |
| 214 ValueStoreCache* cache = it->second; | 214 ValueStoreCache* cache = it->second; |
| 215 cache->ShutdownOnUI(); | 215 cache->ShutdownOnUI(); |
| 216 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, cache); | 216 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, cache); |
| 217 caches_.erase(it); | 217 caches_.erase(it); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 // ProfileKeyedAPI implementation. | 221 // BrowserContextKeyedAPI implementation. |
| 222 | 222 |
| 223 // static | 223 // static |
| 224 ProfileKeyedAPIFactory<SettingsFrontend>* | 224 BrowserContextKeyedAPIFactory<SettingsFrontend>* |
| 225 SettingsFrontend::GetFactoryInstance() { | 225 SettingsFrontend::GetFactoryInstance() { |
| 226 return g_factory.Pointer(); | 226 return g_factory.Pointer(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 // static | 229 // static |
| 230 const char* SettingsFrontend::service_name() { | 230 const char* SettingsFrontend::service_name() { |
| 231 return "SettingsFrontend"; | 231 return "SettingsFrontend"; |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace extensions | 234 } // namespace extensions |
| OLD | NEW |