Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.h

Issue 165223003: Add a Restore() method to ValueStore and make StorageAPI use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "sync/api/syncable_service.h"
15 16
16 namespace base { 17 namespace base {
17 class FilePath; 18 class FilePath;
18 } 19 }
19 20
21 namespace syncer {
22 class SyncableService;
23 }
24
20 namespace extensions { 25 namespace extensions {
21 26
22 class SettingsBackend; 27 class SettingsBackend;
23 class SettingsStorageFactory; 28 class SettingsStorageFactory;
24 29
25 // ValueStoreCache for the LOCAL and SYNC namespaces. It owns a backend for 30 // ValueStoreCache for the LOCAL and SYNC namespaces. It owns a backend for
26 // apps and another for extensions. Each backend takes care of persistence and 31 // apps and another for extensions. Each backend takes care of persistence and
27 // syncing. 32 // syncing.
28 class SyncOrLocalValueStoreCache : public ValueStoreCache { 33 class SyncOrLocalValueStoreCache : public ValueStoreCache {
29 public: 34 public:
30 SyncOrLocalValueStoreCache( 35 SyncOrLocalValueStoreCache(
31 settings_namespace::Namespace settings_namespace, 36 settings_namespace::Namespace settings_namespace,
32 const scoped_refptr<SettingsStorageFactory>& factory, 37 const scoped_refptr<SettingsStorageFactory>& factory,
33 const SettingsStorageQuotaEnforcer::Limits& quota, 38 const SettingsStorageQuotaEnforcer::Limits& quota,
34 const scoped_refptr<SettingsObserverList>& observers, 39 const scoped_refptr<SettingsObserverList>& observers,
35 const base::FilePath& profile_path); 40 const base::FilePath& profile_path);
36 virtual ~SyncOrLocalValueStoreCache(); 41 virtual ~SyncOrLocalValueStoreCache();
37 42
38 SettingsBackend* GetAppBackend() const; 43 syncer::SyncableService* GetSyncableService(syncer::ModelType type) const;
39 SettingsBackend* GetExtensionBackend() const;
40 44
41 // ValueStoreCache implementation: 45 // ValueStoreCache implementation:
42 46
43 virtual void RunWithValueStoreForExtension( 47 virtual void RunWithValueStoreForExtension(
44 const StorageCallback& callback, 48 const StorageCallback& callback,
45 scoped_refptr<const Extension> extension) OVERRIDE; 49 scoped_refptr<const Extension> extension) OVERRIDE;
46 50
47 virtual void DeleteStorageSoon(const std::string& extension_id) OVERRIDE; 51 virtual void DeleteStorageSoon(const std::string& extension_id) OVERRIDE;
48 52
49 private: 53 private:
50 void InitOnFileThread(const scoped_refptr<SettingsStorageFactory>& factory, 54 void InitOnFileThread(const scoped_refptr<SettingsStorageFactory>& factory,
51 const SettingsStorageQuotaEnforcer::Limits& quota, 55 const SettingsStorageQuotaEnforcer::Limits& quota,
52 const scoped_refptr<SettingsObserverList>& observers, 56 const scoped_refptr<SettingsObserverList>& observers,
53 const base::FilePath& profile_path); 57 const base::FilePath& profile_path);
54 58
55 settings_namespace::Namespace settings_namespace_; 59 settings_namespace::Namespace settings_namespace_;
60 bool initialized_;
56 scoped_ptr<SettingsBackend> app_backend_; 61 scoped_ptr<SettingsBackend> app_backend_;
57 scoped_ptr<SettingsBackend> extension_backend_; 62 scoped_ptr<SettingsBackend> extension_backend_;
58 63
59 DISALLOW_COPY_AND_ASSIGN(SyncOrLocalValueStoreCache); 64 DISALLOW_COPY_AND_ASSIGN(SyncOrLocalValueStoreCache);
60 }; 65 };
61 66
62 } // namespace extensions 67 } // namespace extensions
63 68
64 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE _H_ 69 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698