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

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

Issue 189263013: Move extensions storage API implementation to src/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (move_storage) Created 6 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/api/storage/settings_observer.h"
14 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h"
15 #include "chrome/browser/extensions/api/storage/value_store_cache.h"
16 #include "extensions/browser/api/storage/settings_namespace.h"
17 #include "extensions/browser/browser_context_keyed_api_factory.h"
18
19 namespace content {
20 class BrowserContext;
21 }
22
23 namespace extensions {
24
25 // The component of extension settings which runs on the UI thread, as opposed
26 // to SettingsBackend which lives on the FILE thread.
27 class SettingsFrontend : public BrowserContextKeyedAPI {
28 public:
29 // Returns the current instance for |context|.
30 static SettingsFrontend* Get(content::BrowserContext* context);
31
32 // Creates with a specific |storage_factory|. Caller owns the object.
33 static SettingsFrontend* CreateForTesting(
34 const scoped_refptr<SettingsStorageFactory>& storage_factory,
35 content::BrowserContext* context);
36
37 // Public so tests can create and delete their own instances.
38 virtual ~SettingsFrontend();
39
40 // Returns the value store cache for |settings_namespace|.
41 ValueStoreCache* GetValueStoreCache(
42 settings_namespace::Namespace settings_namespace) const;
43
44 // Returns true if |settings_namespace| is a valid namespace.
45 bool IsStorageEnabled(settings_namespace::Namespace settings_namespace) const;
46
47 // Runs |callback| with the storage area of the given |settings_namespace|
48 // for the |extension|.
49 void RunWithStorage(scoped_refptr<const Extension> extension,
50 settings_namespace::Namespace settings_namespace,
51 const ValueStoreCache::StorageCallback& callback);
52
53 // Deletes the settings for the given |extension_id|.
54 void DeleteStorageSoon(const std::string& extension_id);
55
56 // Gets the thread-safe observer list.
57 scoped_refptr<SettingsObserverList> GetObservers();
58
59 void DisableStorageForTesting(
60 settings_namespace::Namespace settings_namespace);
61
62 // BrowserContextKeyedAPI implementation.
63 static BrowserContextKeyedAPIFactory<SettingsFrontend>* GetFactoryInstance();
64 static const char* service_name();
65 static const bool kServiceRedirectedInIncognito = true;
66 static const bool kServiceIsNULLWhileTesting = true;
67
68 private:
69 friend class BrowserContextKeyedAPIFactory<SettingsFrontend>;
70
71 typedef std::map<settings_namespace::Namespace, ValueStoreCache*> CacheMap;
72
73 // Constructor for normal BrowserContextKeyedAPI usage.
74 explicit SettingsFrontend(content::BrowserContext* context);
75
76 // Constructor for tests.
77 SettingsFrontend(const scoped_refptr<SettingsStorageFactory>& storage_factory,
78 content::BrowserContext* context);
79
80 void Init(const scoped_refptr<SettingsStorageFactory>& storage_factory);
81
82 // The (non-incognito) browser context this Frontend belongs to.
83 content::BrowserContext* const browser_context_;
84
85 // List of observers to settings changes.
86 scoped_refptr<SettingsObserverList> observers_;
87
88 // Observer for |browser_context_|.
89 scoped_ptr<SettingsObserver> browser_context_observer_;
90
91 // Maps a known namespace to its corresponding ValueStoreCache. The caches
92 // are owned by this object.
93 CacheMap caches_;
94
95 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend);
96 };
97
98 } // namespace extensions
99
100 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/storage/settings_backend.cc ('k') | chrome/browser/extensions/api/storage/settings_frontend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698