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

Side by Side Diff: chrome/browser/extensions/settings/settings_backend.h

Issue 8670012: Extension Settings API: move the API functions into an object SettingsNamepace, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug / sync Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SETTINGS_SETTINGS_BACKEND_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 10 matching lines...) Expand all
21 21
22 // Manages SettingsStorage objects for extensions, including routing 22 // Manages SettingsStorage objects for extensions, including routing
23 // changes from sync to them. 23 // changes from sync to them.
24 // Lives entirely on the FILE thread. 24 // Lives entirely on the FILE thread.
25 class SettingsBackend : public SyncableService { 25 class SettingsBackend : public SyncableService {
26 public: 26 public:
27 // |storage_factory| is use to create leveldb storage areas. 27 // |storage_factory| is use to create leveldb storage areas.
28 // |base_path| is the base of the extension settings directory, so the 28 // |base_path| is the base of the extension settings directory, so the
29 // databases will be at base_path/extension_id. 29 // databases will be at base_path/extension_id.
30 // |observers| is the list of observers to settings changes. 30 // |observers| is the list of observers to settings changes.
31 explicit SettingsBackend( 31 SettingsBackend(
32 // Ownership NOT taken. 32 const scoped_refptr<SettingsStorageFactory>& storage_factory,
33 SettingsStorageFactory* storage_factory,
34 const FilePath& base_path, 33 const FilePath& base_path,
35 const scoped_refptr<SettingsObserverList>& observers); 34 const scoped_refptr<SettingsObserverList>& observers);
36 35
37 virtual ~SettingsBackend(); 36 virtual ~SettingsBackend();
38 37
39 // Gets a weak reference to the storage area for a given extension. 38 // Gets a weak reference to the storage area for a given extension.
40 // Must be run on the FILE thread. 39 // Must be run on the FILE thread.
41 SettingsStorage* GetStorage(const std::string& extension_id) const; 40 SettingsStorage* GetStorage(const std::string& extension_id) const;
42 41
43 // Deletes all setting data for an extension. Call on the FILE thread. 42 // Deletes all setting data for an extension. Call on the FILE thread.
(...skipping 19 matching lines...) Expand all
63 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( 62 SyncableSettingsStorage* GetOrCreateStorageWithSyncData(
64 const std::string& extension_id, const DictionaryValue& sync_data) const; 63 const std::string& extension_id, const DictionaryValue& sync_data) const;
65 64
66 // Gets all extension IDs known to extension settings. This may not be all 65 // Gets all extension IDs known to extension settings. This may not be all
67 // installed extensions. 66 // installed extensions.
68 std::set<std::string> GetKnownExtensionIDs() const; 67 std::set<std::string> GetKnownExtensionIDs() const;
69 68
70 // Disable the syncing of the storage area for |extension_id|. 69 // Disable the syncing of the storage area for |extension_id|.
71 void DisableSyncForExtension(const std::string& extension_id) const; 70 void DisableSyncForExtension(const std::string& extension_id) const;
72 71
73 // The Factory to use for creating leveldb storage areas. Not owned. 72 // The Factory to use for creating leveldb storage areas.
74 SettingsStorageFactory* const storage_factory_; 73 const scoped_refptr<SettingsStorageFactory> storage_factory_;
75 74
76 // The base file path to create any leveldb databases at. 75 // The base file path to create any leveldb databases at.
77 const FilePath base_path_; 76 const FilePath base_path_;
78 77
79 // The list of observers to settings changes. 78 // The list of observers to settings changes.
80 const scoped_refptr<SettingsObserverList> observers_; 79 const scoped_refptr<SettingsObserverList> observers_;
81 80
82 // A cache of SettingsStorage objects that have already been created. 81 // A cache of SettingsStorage objects that have already been created.
83 // Ensure that there is only ever one created per extension. 82 // Ensure that there is only ever one created per extension.
84 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > 83 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> >
85 StorageObjMap; 84 StorageObjMap;
86 mutable StorageObjMap storage_objs_; 85 mutable StorageObjMap storage_objs_;
87 86
88 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled 87 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled
89 // yet, and either SETTINGS or APP_SETTINGS if it has been. 88 // yet, and either SETTINGS or APP_SETTINGS if it has been.
90 syncable::ModelType sync_type_; 89 syncable::ModelType sync_type_;
91 90
92 // Current sync processor, if any. 91 // Current sync processor, if any.
93 SyncChangeProcessor* sync_processor_; 92 SyncChangeProcessor* sync_processor_;
94 93
95 DISALLOW_COPY_AND_ASSIGN(SettingsBackend); 94 DISALLOW_COPY_AND_ASSIGN(SettingsBackend);
96 }; 95 };
97 96
98 } // namespace extensions 97 } // namespace extensions
99 98
100 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ 99 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/settings/settings_apitest.cc ('k') | chrome/browser/extensions/settings/settings_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698