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