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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_backend.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_BACKEND_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_
7
8 #include <string>
9
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer. h"
14
15 namespace syncer {
16 class SyncableService;
17 }
18
19 class ValueStore;
20
21 namespace extensions {
22 class SettingsStorageFactory;
23
24 // Performs work for the storage API on the FILE thread.
25 class SettingsBackend {
26 public:
27 SettingsBackend(const scoped_refptr<SettingsStorageFactory>& storage_factory,
28 const base::FilePath& base_path,
29 const SettingsStorageQuotaEnforcer::Limits& quota);
30 virtual ~SettingsBackend();
31
32 // Gets a weak reference to the storage area for |extension_id|.
33 // Must be run on the FILE thread.
34 virtual ValueStore* GetStorage(const std::string& extension_id) = 0;
35
36 // Deletes all setting data for an extension. Call on the FILE thread.
37 virtual void DeleteStorage(const std::string& extension_id) = 0;
38
39 // A slight hack so we can get a SyncableService from a SettingsBackend if
40 // it's actually a SyncStorageBackend. If called on a LocalStorageBackend,
41 // this asserts and returns null.
42 virtual syncer::SyncableService* GetAsSyncableService();
43
44 SettingsStorageFactory* storage_factory() const {
45 return storage_factory_.get();
46 }
47 const base::FilePath& base_path() const { return base_path_; }
48 const SettingsStorageQuotaEnforcer::Limits& quota() const { return quota_; }
49
50 protected:
51 // Creates a ValueStore decorated with quota-enforcing behavior (the default
52 // for both sync and local stores). If the database is corrupt,
53 // SettingsStorageQuotaEnforcer will try and restore it as part of the
54 // initialization process (by necessity, since we need to read the database to
55 // calculate the storage).
56 scoped_ptr<SettingsStorageQuotaEnforcer> CreateStorageForExtension(
57 const std::string& extension_id) const;
58
59 private:
60 // The Factory to use for creating new ValueStores.
61 const scoped_refptr<SettingsStorageFactory> storage_factory_;
62
63 // The base file path to use when creating new ValueStores.
64 const base::FilePath base_path_;
65
66 // Quota limits (see SettingsStorageQuotaEnforcer).
67 const SettingsStorageQuotaEnforcer::Limits quota_;
68
69 DISALLOW_COPY_AND_ASSIGN(SettingsBackend);
70 };
71
72 } // namespace extensions
73
74 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/storage/settings_apitest.cc ('k') | chrome/browser/extensions/api/storage/settings_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698