| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_ | 6 #define EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" | 14 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" |
| 15 #include "extensions/browser/api/storage/value_store_cache.h" | 15 #include "extensions/browser/api/storage/value_store_cache.h" |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 class SettingsStorageFactory; | 19 class SettingsStorageFactory; |
| 20 | 20 |
| 21 // ValueStoreCache for the LOCAL namespace. It owns a backend for apps and | 21 // ValueStoreCache for the LOCAL namespace. It owns a backend for apps and |
| 22 // another for extensions. Each backend takes care of persistence. | 22 // another for extensions. Each backend takes care of persistence. |
| 23 class LocalValueStoreCache : public ValueStoreCache { | 23 class LocalValueStoreCache : public ValueStoreCache { |
| 24 public: | 24 public: |
| 25 LocalValueStoreCache(const scoped_refptr<SettingsStorageFactory>& factory, | 25 LocalValueStoreCache(const scoped_refptr<SettingsStorageFactory>& factory, |
| 26 const base::FilePath& profile_path); | 26 const base::FilePath& profile_path); |
| 27 virtual ~LocalValueStoreCache(); | 27 ~LocalValueStoreCache() override; |
| 28 | 28 |
| 29 // ValueStoreCache implementation: | 29 // ValueStoreCache implementation: |
| 30 virtual void RunWithValueStoreForExtension( | 30 void RunWithValueStoreForExtension( |
| 31 const StorageCallback& callback, | 31 const StorageCallback& callback, |
| 32 scoped_refptr<const Extension> extension) override; | 32 scoped_refptr<const Extension> extension) override; |
| 33 virtual void DeleteStorageSoon(const std::string& extension_id) override; | 33 void DeleteStorageSoon(const std::string& extension_id) override; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 typedef std::map<std::string, linked_ptr<ValueStore> > StorageMap; | 36 typedef std::map<std::string, linked_ptr<ValueStore> > StorageMap; |
| 37 | 37 |
| 38 ValueStore* GetStorage(scoped_refptr<const Extension> extension); | 38 ValueStore* GetStorage(scoped_refptr<const Extension> extension); |
| 39 | 39 |
| 40 // The Factory to use for creating new ValueStores. | 40 // The Factory to use for creating new ValueStores. |
| 41 const scoped_refptr<SettingsStorageFactory> storage_factory_; | 41 const scoped_refptr<SettingsStorageFactory> storage_factory_; |
| 42 | 42 |
| 43 // The base path to use for extensions when creating new ValueStores. | 43 // The base path to use for extensions when creating new ValueStores. |
| 44 const base::FilePath extension_base_path_; | 44 const base::FilePath extension_base_path_; |
| 45 | 45 |
| 46 // The base path to use for apps when creating new ValueStores. | 46 // The base path to use for apps when creating new ValueStores. |
| 47 const base::FilePath app_base_path_; | 47 const base::FilePath app_base_path_; |
| 48 | 48 |
| 49 // Quota limits (see SettingsStorageQuotaEnforcer). | 49 // Quota limits (see SettingsStorageQuotaEnforcer). |
| 50 const SettingsStorageQuotaEnforcer::Limits quota_; | 50 const SettingsStorageQuotaEnforcer::Limits quota_; |
| 51 | 51 |
| 52 // The collection of ValueStores for local storage. | 52 // The collection of ValueStores for local storage. |
| 53 StorageMap storage_map_; | 53 StorageMap storage_map_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(LocalValueStoreCache); | 55 DISALLOW_COPY_AND_ASSIGN(LocalValueStoreCache); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 } // namespace extensions | 58 } // namespace extensions |
| 59 | 59 |
| 60 #endif // EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_ | 60 #endif // EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_ |
| OLD | NEW |