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

Side by Side Diff: chrome/browser/extensions/extension_settings.h

Issue 7189029: Implement an initial extension settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Change where extension settings are saved, update TODO, api test Created 9 years, 6 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) 2011 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_EXTENSION_SETTINGS_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_H_
7 #pragma once
8
9 #include "base/file_path.h"
10 #include "chrome/browser/extensions/extension_settings_storage.h"
Mihai Parparita -not on Chrome 2011/06/21 23:40:11 Can you just forward declare ExtensionSettingsStor
not at google - send to devlin 2011/06/22 09:40:38 Done.
11 #include "third_party/leveldb/include/leveldb/db.h"
Mihai Parparita -not on Chrome 2011/06/21 23:40:11 Doesn't seem like you need this include at all.
not at google - send to devlin 2011/06/22 09:40:38 Done.
12
13 // Manages ExtensionSettingsStorage objects for extensions.
14 class ExtensionSettings {
15 public:
16 // File path is the base of the extension settings directory.
17 // The databases will be at base_path/extension_id.
18 explicit ExtensionSettings(const FilePath& base_path);
19 ~ExtensionSettings();
20
21 // Callback for the GetStorage() methods. The callback will always be Run()
22 // from a PostMessage to the UI thread, even if the storage area is cached.
23 class Callback {
24 public:
25 virtual ~Callback() {}
26
27 // Called when the storage area is available. Ownership of the object
28 // remains with the ExtensionSettings object.
29 virtual void Run(ExtensionSettingsStorage* storage) = 0;
30 };
31
32 // Gets the storage area for a given extension.
33 // By default this will be of type LEVELDB|CACHED, but on failure to create
34 // a leveldb instance will fall back to NOOP|CACHED.
Mihai Parparita -not on Chrome 2011/06/21 23:40:11 I'm not sure that the fallback behavior is a great
not at google - send to devlin 2011/06/22 09:40:38 What should the failure behaviour be then? Just e
35 // Callback objects will be deleted when used.
36 void GetStorage(const std::string& extension_id, Callback* callback);
37
38 // Gets a storage area for a given extension, with a specific type, either
39 // NOOP, LEVELDB, NOOP|CACHED, or LEVELDB|CACHED.
40 // Use this for testing; if the given type fails to be created (e.g. if
41 // leveldb creation fails) then a DCHECK will fail.
42 // Callback objects will be deleted when used.
43 void GetStorageForTesting(int type, const std::string& extension_id,
44 Callback* callback);
45
46 private:
Mihai Parparita -not on Chrome 2011/06/21 23:40:11 Should add DISALLOW_COPY_AND_ASSIGN.
not at google - send to devlin 2011/06/22 09:40:38 Done.
47 // Attempts to get and callback with an existing storage area. Returns
48 // whether storage existed and the callback run.
49 bool GetExistingStorage(const std::string& extension_id, Callback* callback);
50
51 const FilePath base_path_;
52 std::map<std::string, ExtensionSettingsStorage*> storage_objs_;
53 };
54
55 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698