Chromium Code Reviews| Index: webkit/dom_storage/local_storage_database.h |
| diff --git a/webkit/dom_storage/local_storage_database.h b/webkit/dom_storage/local_storage_database.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7554075f6c63de3cfd9a6d89b44fd030cea8c3c0 |
| --- /dev/null |
| +++ b/webkit/dom_storage/local_storage_database.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright (c) 2012 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 WEBKIT_DOM_STORAGE_LOCAL_STORAGE_DATABASE_H_ |
| +#define WEBKIT_DOM_STORAGE_LOCAL_STORAGE_DATABASE_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/file_path.h" |
| +#include "base/gtest_prod_util.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/string16.h" |
| +#include "sql/connection.h" |
| +#include "sql/meta_table.h" |
| + |
| +namespace dom_storage { |
| + |
| +class LocalStorageDatabase { |
|
michaeln
2012/01/24 17:43:40
class DOMStorageDatabase... for consistency with o
benm (inactive)
2012/01/24 17:51:07
sgtm
|
| + public: |
| + explicit LocalStorageDatabase(const FilePath& file_path); |
| + virtual ~LocalStorageDatabase(); |
| + |
| + bool Open(); |
| + void Close(); |
| + bool Init(); |
| + |
| + std::map<string16, string16> ReadAllValues() const; |
| + bool WriteAllValues(const std::map<string16, string16>& values); |
|
michaeln
2012/01/24 00:18:16
We should figure out the read/write access pattern
benm (inactive)
2012/01/24 10:47:01
Yeah, I thought about this when I started drafting
|
| + |
| + int GetVersionNumber() { return meta_table_.GetVersionNumber(); } |
| + bool IsOpen() const { return db_.get() ? db_->is_open() : false; } |
| + |
| + private: |
| + FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, SimpleOpenInitAndClose); |
| + FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, |
| + TestInitUpgradesV1TableToV2); |
| + FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, SimpleRead); |
| + FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, SimpleWrite); |
| + FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, UpgradeFromV1ToV2NoData); |
| + FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, |
| + UpgradeFromV1ToV2WithData); |
| + FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, |
| + TestOpenCloseDataPreserved); |
| + |
| + bool CreateTable(); |
| + bool UpgradeVersion1To2IfNeeded(); |
| + |
| + // Path to the database on disk. |
| + FilePath file_path_; |
| + |
| + scoped_ptr<sql::Connection> db_; |
| + sql::MetaTable meta_table_; |
| +}; |
| + |
| +} // namespace dom_storage |
| + |
| +#endif // WEBKIT_DOM_STORAGE_LOCAL_STORAGE_DATABASE_H_ |