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

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

Issue 8497065: Extension Settings API: make it so that when leveldb storage areas fail to be (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/observer_list_threadsafe.h" 13 #include "base/observer_list_threadsafe.h"
14 #include "base/task.h" 14 #include "base/task.h"
15 #include "chrome/browser/extensions/settings/settings_leveldb_storage.h"
15 #include "chrome/browser/extensions/settings/settings_observer.h" 16 #include "chrome/browser/extensions/settings/settings_observer.h"
16 #include "chrome/browser/extensions/settings/syncable_settings_storage.h" 17 #include "chrome/browser/extensions/settings/syncable_settings_storage.h"
17 #include "chrome/browser/sync/api/syncable_service.h" 18 #include "chrome/browser/sync/api/syncable_service.h"
18 19
19 namespace extensions { 20 namespace extensions {
20 21
21 // Manages SettingsStorage objects for extensions, including routing 22 // Manages SettingsStorage objects for extensions, including routing
22 // changes from sync to them. 23 // changes from sync to them.
23 // Lives entirely on the FILE thread. 24 // Lives entirely on the FILE thread.
24 class SettingsBackend : public SyncableService { 25 class SettingsBackend : public SyncableService {
25 public: 26 public:
27 // |storage_factory| is use to create leveldb storage areas.
26 // |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
27 // databases will be at base_path/extension_id. 29 // databases will be at base_path/extension_id.
28 // |observers| is the list of observers to settings changes. 30 // |observers| is the list of observers to settings changes.
29 explicit SettingsBackend( 31 explicit SettingsBackend(
32 // Ownership NOT taken.
33 SettingsStorageFactory* storage_factory,
30 const FilePath& base_path, 34 const FilePath& base_path,
31 const scoped_refptr<SettingsObserverList>& observers); 35 const scoped_refptr<SettingsObserverList>& observers);
32 36
33 virtual ~SettingsBackend(); 37 virtual ~SettingsBackend();
34 38
35 // Gets a weak reference to the storage area for a given extension. 39 // Gets a weak reference to the storage area for a given extension.
36 // Must be run on the FILE thread. 40 // Must be run on the FILE thread.
37 // 41 //
38 // By default this will be an SettingsLeveldbStorage, but on 42 // By default this will be an SettingsLeveldbStorage, but on
39 // failure to create a leveldb instance will fall back to 43 // failure to create a leveldb instance will fall back to
(...skipping 21 matching lines...) Expand all
61 // 65 //
62 // By default this will be of a cached LEVELDB storage, but on failure to 66 // By default this will be of a cached LEVELDB storage, but on failure to
63 // create a leveldb instance will fall back to cached NOOP storage. 67 // create a leveldb instance will fall back to cached NOOP storage.
64 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( 68 SyncableSettingsStorage* GetOrCreateStorageWithSyncData(
65 const std::string& extension_id, const DictionaryValue& sync_data) const; 69 const std::string& extension_id, const DictionaryValue& sync_data) const;
66 70
67 // Gets all extension IDs known to extension settings. This may not be all 71 // Gets all extension IDs known to extension settings. This may not be all
68 // installed extensions. 72 // installed extensions.
69 std::set<std::string> GetKnownExtensionIDs() const; 73 std::set<std::string> GetKnownExtensionIDs() const;
70 74
75 // The Factory to use for creating leveldb storage areas. Not owned.
76 SettingsStorageFactory* const storage_factory_;
Matt Perry 2011/11/11 00:49:38 Is there a reason this is const? This will just pr
not at google - send to devlin 2011/11/12 02:10:27 Yep that was deliberate. It could be "const Setti
77
71 // The base file path to create any leveldb databases at. 78 // The base file path to create any leveldb databases at.
72 const FilePath base_path_; 79 const FilePath base_path_;
73 80
74 // The list of observers to settings changes. 81 // The list of observers to settings changes.
75 const scoped_refptr<SettingsObserverList> observers_; 82 const scoped_refptr<SettingsObserverList> observers_;
76 83
77 // A cache of SettingsStorage objects that have already been created. 84 // A cache of SettingsStorage objects that have already been created.
78 // Ensure that there is only ever one created per extension. 85 // Ensure that there is only ever one created per extension.
79 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > 86 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> >
80 StorageObjMap; 87 StorageObjMap;
81 mutable StorageObjMap storage_objs_; 88 mutable StorageObjMap storage_objs_;
82 89
83 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled 90 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled
84 // yet, and either SETTINGS or APP_SETTINGS if it has been. 91 // yet, and either SETTINGS or APP_SETTINGS if it has been.
85 syncable::ModelType sync_type_; 92 syncable::ModelType sync_type_;
86 93
87 // Current sync processor, if any. 94 // Current sync processor, if any.
88 SyncChangeProcessor* sync_processor_; 95 SyncChangeProcessor* sync_processor_;
89 96
90 DISALLOW_COPY_AND_ASSIGN(SettingsBackend); 97 DISALLOW_COPY_AND_ASSIGN(SettingsBackend);
91 }; 98 };
92 99
93 } // namespace extensions 100 } // namespace extensions
94 101
95 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ 102 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698