Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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 WEBKIT_DOM_STORAGE_LOCAL_STORAGE_DATABASE_H_ | |
| 6 #define WEBKIT_DOM_STORAGE_LOCAL_STORAGE_DATABASE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/file_path.h" | |
| 11 #include "base/gtest_prod_util.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/string16.h" | |
| 14 #include "sql/connection.h" | |
| 15 #include "sql/meta_table.h" | |
| 16 | |
| 17 namespace dom_storage { | |
| 18 | |
| 19 class LocalStorageDatabase { | |
|
michaeln
2012/01/24 17:43:40
class DOMStorageDatabase... for consistency with o
benm (inactive)
2012/01/24 17:51:07
sgtm
| |
| 20 public: | |
| 21 explicit LocalStorageDatabase(const FilePath& file_path); | |
| 22 virtual ~LocalStorageDatabase(); | |
| 23 | |
| 24 bool Open(); | |
| 25 void Close(); | |
| 26 bool Init(); | |
| 27 | |
| 28 std::map<string16, string16> ReadAllValues() const; | |
| 29 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
| |
| 30 | |
| 31 int GetVersionNumber() { return meta_table_.GetVersionNumber(); } | |
| 32 bool IsOpen() const { return db_.get() ? db_->is_open() : false; } | |
| 33 | |
| 34 private: | |
| 35 FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, SimpleOpenInitAndClose); | |
| 36 FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, | |
| 37 TestInitUpgradesV1TableToV2); | |
| 38 FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, SimpleRead); | |
| 39 FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, SimpleWrite); | |
| 40 FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, UpgradeFromV1ToV2NoData); | |
| 41 FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, | |
| 42 UpgradeFromV1ToV2WithData); | |
| 43 FRIEND_TEST_ALL_PREFIXES(LocalStorageDatabaseTest, | |
| 44 TestOpenCloseDataPreserved); | |
| 45 | |
| 46 bool CreateTable(); | |
| 47 bool UpgradeVersion1To2IfNeeded(); | |
| 48 | |
| 49 // Path to the database on disk. | |
| 50 FilePath file_path_; | |
| 51 | |
| 52 scoped_ptr<sql::Connection> db_; | |
| 53 sql::MetaTable meta_table_; | |
| 54 }; | |
| 55 | |
| 56 } // namespace dom_storage | |
| 57 | |
| 58 #endif // WEBKIT_DOM_STORAGE_LOCAL_STORAGE_DATABASE_H_ | |
| OLD | NEW |