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