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