| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_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/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/api/storage/settings_observer.h" | 12 #include "chrome/browser/extensions/api/storage/settings_observer.h" |
| 13 #include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.
h" | 13 #include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.
h" |
| 14 #include "chrome/browser/extensions/api/storage/value_store_cache.h" | 14 #include "chrome/browser/extensions/api/storage/value_store_cache.h" |
| 15 | 15 |
| 16 namespace base { |
| 16 class FilePath; | 17 class FilePath; |
| 18 } |
| 17 | 19 |
| 18 namespace extensions { | 20 namespace extensions { |
| 19 | 21 |
| 20 class SettingsBackend; | 22 class SettingsBackend; |
| 21 class SettingsStorageFactory; | 23 class SettingsStorageFactory; |
| 22 | 24 |
| 23 // ValueStoreCache for the LOCAL and SYNC namespaces. It owns a backend for | 25 // ValueStoreCache for the LOCAL and SYNC namespaces. It owns a backend for |
| 24 // apps and another for extensions. Each backend takes care of persistence and | 26 // apps and another for extensions. Each backend takes care of persistence and |
| 25 // syncing. | 27 // syncing. |
| 26 class SyncOrLocalValueStoreCache : public ValueStoreCache { | 28 class SyncOrLocalValueStoreCache : public ValueStoreCache { |
| 27 public: | 29 public: |
| 28 SyncOrLocalValueStoreCache( | 30 SyncOrLocalValueStoreCache( |
| 29 settings_namespace::Namespace settings_namespace, | 31 settings_namespace::Namespace settings_namespace, |
| 30 const scoped_refptr<SettingsStorageFactory>& factory, | 32 const scoped_refptr<SettingsStorageFactory>& factory, |
| 31 const SettingsStorageQuotaEnforcer::Limits& quota, | 33 const SettingsStorageQuotaEnforcer::Limits& quota, |
| 32 const scoped_refptr<SettingsObserverList>& observers, | 34 const scoped_refptr<SettingsObserverList>& observers, |
| 33 const FilePath& profile_path); | 35 const base::FilePath& profile_path); |
| 34 virtual ~SyncOrLocalValueStoreCache(); | 36 virtual ~SyncOrLocalValueStoreCache(); |
| 35 | 37 |
| 36 SettingsBackend* GetAppBackend() const; | 38 SettingsBackend* GetAppBackend() const; |
| 37 SettingsBackend* GetExtensionBackend() const; | 39 SettingsBackend* GetExtensionBackend() const; |
| 38 | 40 |
| 39 // ValueStoreCache implementation: | 41 // ValueStoreCache implementation: |
| 40 | 42 |
| 41 virtual void RunWithValueStoreForExtension( | 43 virtual void RunWithValueStoreForExtension( |
| 42 const StorageCallback& callback, | 44 const StorageCallback& callback, |
| 43 scoped_refptr<const Extension> extension) OVERRIDE; | 45 scoped_refptr<const Extension> extension) OVERRIDE; |
| 44 | 46 |
| 45 virtual void DeleteStorageSoon(const std::string& extension_id) OVERRIDE; | 47 virtual void DeleteStorageSoon(const std::string& extension_id) OVERRIDE; |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 void InitOnFileThread(const scoped_refptr<SettingsStorageFactory>& factory, | 50 void InitOnFileThread(const scoped_refptr<SettingsStorageFactory>& factory, |
| 49 const SettingsStorageQuotaEnforcer::Limits& quota, | 51 const SettingsStorageQuotaEnforcer::Limits& quota, |
| 50 const scoped_refptr<SettingsObserverList>& observers, | 52 const scoped_refptr<SettingsObserverList>& observers, |
| 51 const FilePath& profile_path); | 53 const base::FilePath& profile_path); |
| 52 | 54 |
| 53 settings_namespace::Namespace settings_namespace_; | 55 settings_namespace::Namespace settings_namespace_; |
| 54 scoped_ptr<SettingsBackend> app_backend_; | 56 scoped_ptr<SettingsBackend> app_backend_; |
| 55 scoped_ptr<SettingsBackend> extension_backend_; | 57 scoped_ptr<SettingsBackend> extension_backend_; |
| 56 | 58 |
| 57 DISALLOW_COPY_AND_ASSIGN(SyncOrLocalValueStoreCache); | 59 DISALLOW_COPY_AND_ASSIGN(SyncOrLocalValueStoreCache); |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 } // namespace extensions | 62 } // namespace extensions |
| 61 | 63 |
| 62 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE
_H_ | 64 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE
_H_ |
| OLD | NEW |