Chromium Code Reviews| Index: chrome/browser/extensions/extension_settings.h |
| diff --git a/chrome/browser/extensions/extension_settings.h b/chrome/browser/extensions/extension_settings.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6a867aa9b086b58b873ecd11be010066bc041e99 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_settings.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_H_ |
| +#pragma once |
| + |
| +#include "base/file_path.h" |
| +#include "chrome/browser/extensions/extension_settings_storage.h" |
| + |
| +// Manages ExtensionSettingsStorage objects for extensions. |
| +class ExtensionSettings { |
| + public: |
| + // File path is the base of the extension settings directory. |
| + // The databases will be at base_path/extension_id. |
| + explicit ExtensionSettings(const FilePath& base_path); |
| + ~ExtensionSettings(); |
| + |
| + // Callback for the GetStorage() methods. The callback will always be Run() |
| + // from a PostMessage to the UI thread, even if the storage area is cached. |
| + class Callback { |
| + public: |
| + virtual ~Callback() {} |
| + |
| + // Called when the storage area is available. Ownership of the object |
| + // remains with the ExtensionSettings object. |
| + virtual void Run(ExtensionSettingsStorage* storage) = 0; |
| + }; |
| + |
| + // Gets the storage area for a given extension. |
| + // By default this will be of a cached LEVELDB storage, but on failure to |
| + // create a leveldb instance will fall back to cached NOOP storage. |
| + // Callback objects will be deleted when used. |
| + void GetStorage(const std::string& extension_id, Callback* callback); |
| + |
| + // Gets a storage area for a given extension with a specific type. |
| + // and whether it should be wrapped in a cache. |
| + // Use this for testing; if the given type fails to be created (e.g. if |
| + // leveldb creation fails) then a DCHECK will fail. |
| + // Callback objects will be deleted when used. |
| + void GetStorageForTesting( |
| + ExtensionSettingsStorage::Type type, |
| + bool cached, |
| + const std::string& extension_id, |
| + Callback* callback); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ExtensionSettings); |
|
Matt Perry
2011/06/23 18:11:45
this should be the very last thing in the class
not at google - send to devlin
2011/06/27 08:51:02
Done.
|
| + |
| + // Attempts to get and callback with an existing storage area. Returns |
| + // whether storage existed and the callback run. |
| + bool GetExistingStorage(const std::string& extension_id, Callback* callback); |
| + |
| + const FilePath base_path_; |
| + std::map<std::string, ExtensionSettingsStorage*> storage_objs_; |
|
Matt Perry
2011/06/23 18:11:45
please document these member vars
not at google - send to devlin
2011/06/27 08:51:02
Done.
|
| +}; |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_H_ |