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

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

Issue 15404005: sync: deferred initialization support for app/extension settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with util fix Created 7 years, 7 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 | Annotate | Revision Log
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_SETTINGS_BACKEND_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 22 matching lines...) Expand all
33 // Lives entirely on the FILE thread. 33 // Lives entirely on the FILE thread.
34 class SettingsBackend : public syncer::SyncableService { 34 class SettingsBackend : public syncer::SyncableService {
35 public: 35 public:
36 // |storage_factory| is use to create leveldb storage areas. 36 // |storage_factory| is use to create leveldb storage areas.
37 // |base_path| is the base of the extension settings directory, so the 37 // |base_path| is the base of the extension settings directory, so the
38 // databases will be at base_path/extension_id. 38 // databases will be at base_path/extension_id.
39 // |observers| is the list of observers to settings changes. 39 // |observers| is the list of observers to settings changes.
40 SettingsBackend( 40 SettingsBackend(
41 const scoped_refptr<SettingsStorageFactory>& storage_factory, 41 const scoped_refptr<SettingsStorageFactory>& storage_factory,
42 const base::FilePath& base_path, 42 const base::FilePath& base_path,
43 syncer::ModelType sync_type,
43 const SettingsStorageQuotaEnforcer::Limits& quota, 44 const SettingsStorageQuotaEnforcer::Limits& quota,
44 const scoped_refptr<SettingsObserverList>& observers); 45 const scoped_refptr<SettingsObserverList>& observers);
45 46
46 virtual ~SettingsBackend(); 47 virtual ~SettingsBackend();
47 48
48 // Gets a weak reference to the storage area for |extension_id|. 49 // Gets a weak reference to the storage area for |extension_id|.
49 // Must be run on the FILE thread. 50 // Must be run on the FILE thread.
50 ValueStore* GetStorage(const std::string& extension_id) const; 51 ValueStore* GetStorage(const std::string& extension_id) const;
51 52
52 // Deletes all setting data for an extension. Call on the FILE thread. 53 // Deletes all setting data for an extension. Call on the FILE thread.
53 void DeleteStorage(const std::string& extension_id); 54 void DeleteStorage(const std::string& extension_id);
54 55
55 // syncer::SyncableService implementation. 56 // syncer::SyncableService implementation.
56 virtual syncer::SyncDataList GetAllSyncData( 57 virtual syncer::SyncDataList GetAllSyncData(
57 syncer::ModelType type) const OVERRIDE; 58 syncer::ModelType type) const OVERRIDE;
58 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( 59 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
59 syncer::ModelType type, 60 syncer::ModelType type,
60 const syncer::SyncDataList& initial_sync_data, 61 const syncer::SyncDataList& initial_sync_data,
61 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 62 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
62 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE; 63 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
63 virtual syncer::SyncError ProcessSyncChanges( 64 virtual syncer::SyncError ProcessSyncChanges(
64 const tracked_objects::Location& from_here, 65 const tracked_objects::Location& from_here,
65 const syncer::SyncChangeList& change_list) OVERRIDE; 66 const syncer::SyncChangeList& change_list) OVERRIDE;
66 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; 67 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
67 68
69 // Provides a StartSyncFlare to the SyncableService. See
70 // sync_start_util for more.
71 void InjectStartSyncFlare(
72 const syncer::SyncableService::StartSyncFlare& flare);
73
68 private: 74 private:
69 // Gets a weak reference to the storage area for a given extension, 75 // Gets a weak reference to the storage area for a given extension,
70 // initializing sync with some initial data if sync enabled. 76 // initializing sync with some initial data if sync enabled.
71 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( 77 SyncableSettingsStorage* GetOrCreateStorageWithSyncData(
72 const std::string& extension_id, 78 const std::string& extension_id,
73 const DictionaryValue& sync_data) const; 79 const DictionaryValue& sync_data) const;
74 80
75 // Gets all extension IDs known to extension settings. This may not be all 81 // Gets all extension IDs known to extension settings. This may not be all
76 // installed extensions. 82 // installed extensions.
77 std::set<std::string> GetKnownExtensionIDs() const; 83 std::set<std::string> GetKnownExtensionIDs() const;
(...skipping 13 matching lines...) Expand all
91 97
92 // The list of observers to settings changes. 98 // The list of observers to settings changes.
93 const scoped_refptr<SettingsObserverList> observers_; 99 const scoped_refptr<SettingsObserverList> observers_;
94 100
95 // A cache of ValueStore objects that have already been created. 101 // A cache of ValueStore objects that have already been created.
96 // Ensure that there is only ever one created per extension. 102 // Ensure that there is only ever one created per extension.
97 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > 103 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> >
98 StorageObjMap; 104 StorageObjMap;
99 mutable StorageObjMap storage_objs_; 105 mutable StorageObjMap storage_objs_;
100 106
101 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled 107 // Current sync model type. Either EXTENSION_SETTINGS or APP_SETTINGS.
102 // yet, and either SETTINGS or APP_SETTINGS if it has been.
103 syncer::ModelType sync_type_; 108 syncer::ModelType sync_type_;
104 109
105 // Current sync processor, if any. 110 // Current sync processor, if any.
106 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 111 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
107 112
108 // Current sync error handler if any. 113 // Current sync error handler if any.
109 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; 114 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
110 115
116 syncer::SyncableService::StartSyncFlare flare_;
117
111 DISALLOW_COPY_AND_ASSIGN(SettingsBackend); 118 DISALLOW_COPY_AND_ASSIGN(SettingsBackend);
112 }; 119 };
113 120
114 } // namespace extensions 121 } // namespace extensions
115 122
116 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_ 123 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698