OLD | NEW |
(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_LEVELDB_STORAGE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_LEVELDB_STORAGE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" |
| 11 #include "base/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/extension_settings_storage.h" |
| 13 #include "third_party/leveldb/include/leveldb/db.h" |
| 14 |
| 15 // Extension settings storage object, backed by a leveldb database. |
| 16 // No caching is done; that should be handled by wrapping with an |
| 17 // ExtensionSettingsStorageCache. |
| 18 class ExtensionSettingsLeveldbStorage : public ExtensionSettingsStorage { |
| 19 public: |
| 20 // Tries to create a leveldb storage area for an extension at a base path. |
| 21 // Returns NULL if creation fails. |
| 22 // Must be run on the FILE thread. |
| 23 static ExtensionSettingsLeveldbStorage* Create( |
| 24 const FilePath& base_path, const std::string& extension_id); |
| 25 |
| 26 // Can be run on any thread. |
| 27 virtual void DestroyEventually() OVERRIDE; |
| 28 |
| 29 virtual void Get(const std::string& key, Callback* callback) OVERRIDE; |
| 30 virtual void Get(const ListValue& keys, Callback* callback) OVERRIDE; |
| 31 virtual void Get(Callback* callback) OVERRIDE; |
| 32 virtual void Set( |
| 33 const std::string& key, const Value& value, Callback* callback) OVERRIDE; |
| 34 virtual void Set(const DictionaryValue& values, Callback* callback) OVERRIDE; |
| 35 virtual void Remove(const std::string& key, Callback* callback) OVERRIDE; |
| 36 virtual void Remove(const ListValue& keys, Callback* callback) OVERRIDE; |
| 37 virtual void Clear(Callback *callback) OVERRIDE; |
| 38 |
| 39 private: |
| 40 // Ownership of db is taken. |
| 41 explicit ExtensionSettingsLeveldbStorage(leveldb::DB* db); |
| 42 // Must be destructed on the FILE thread. |
| 43 ~ExtensionSettingsLeveldbStorage(); |
| 44 |
| 45 scoped_ptr<leveldb::DB> db_; |
| 46 }; |
| 47 |
| 48 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_LEVELDB_STORAGE_H_ |
OLD | NEW |