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

Unified Diff: webkit/dom_storage/local_storage_database.h

Issue 9159020: Create a class to represent a DOM Storage Database. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698