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

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: Use base::Closure for storage callback, style fixes, mac/windows fixes 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/callback.h"
10 #include "base/file_path.h"
11 #include "chrome/browser/extensions/extension_settings_storage.h"
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 from the GetStorage() methods.
22 typedef base::Callback<void(ExtensionSettingsStorage*)> Callback;
23
24 // Gets the storage area for a given extension.
25 // By default this will be of a cached LEVELDB storage, but on failure to
26 // create a leveldb instance will fall back to cached NOOP storage.
27 // Callbacks will happen asynchronously regardless of whether they need to go
28 // to the FILE thread, but will always be called on the UI thread.
29 void GetStorage(const std::string& extension_id, const Callback& callback);
30
31 // Gets a storage area for a given extension with a specific type.
32 // and whether it should be wrapped in a cache.
33 // Use this for testing; if the given type fails to be created (e.g. if
34 // leveldb creation fails) then a DCHECK will fail.
35 // Callback objects will be deleted when used.
36 void GetStorageForTesting(
37 ExtensionSettingsStorage::Type type,
38 bool cached,
39 const std::string& extension_id,
40 const Callback& callback);
41
42 private:
43 DISALLOW_COPY_AND_ASSIGN(ExtensionSettings);
44
45 // Attempts to get and callback with an existing storage area. Returns
46 // whether storage existed and the callback run.
47 bool GetExistingStorage(
48 const std::string& extension_id, const Callback& callback);
49
50 const FilePath base_path_;
51 std::map<std::string, ExtensionSettingsStorage*> storage_objs_;
52 };
53
54 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698