| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_DATABASE_H_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_DATABASE_H_ |
| 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_DATABASE_H_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_DATABASE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // opened. If it does not exist then it will not be created and | 31 // opened. If it does not exist then it will not be created and |
| 32 // |result| will be unmodified. | 32 // |result| will be unmodified. |
| 33 void ReadAllValues(ValuesMap* result); | 33 void ReadAllValues(ValuesMap* result); |
| 34 | 34 |
| 35 // Updates the backing database. Will remove all keys before updating | 35 // Updates the backing database. Will remove all keys before updating |
| 36 // the database if |clear_all_first| is set. Then all entries in | 36 // the database if |clear_all_first| is set. Then all entries in |
| 37 // |changes| will be examined - keys mapped to a null NullableString16 | 37 // |changes| will be examined - keys mapped to a null NullableString16 |
| 38 // will be removed and all others will be inserted/updated as appropriate. | 38 // will be removed and all others will be inserted/updated as appropriate. |
| 39 bool CommitChanges(bool clear_all_first, const ValuesMap& changes); | 39 bool CommitChanges(bool clear_all_first, const ValuesMap& changes); |
| 40 | 40 |
| 41 // Simple getter for the path we were constructed with. |
| 42 const FilePath& file_path() const { return file_path_; } |
| 43 |
| 41 protected: | 44 protected: |
| 42 // Constructor that uses an in-memory sqlite database, for testing. | 45 // Constructor that uses an in-memory sqlite database, for testing. |
| 43 DomStorageDatabase(); | 46 DomStorageDatabase(); |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, SimpleOpenAndClose); | 49 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, SimpleOpenAndClose); |
| 47 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, TestLazyOpenIsLazy); | 50 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, TestLazyOpenIsLazy); |
| 48 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, TestDetectSchemaVersion); | 51 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, TestDetectSchemaVersion); |
| 49 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, | 52 FRIEND_TEST_ALL_PREFIXES(DomStorageDatabaseTest, |
| 50 TestLazyOpenUpgradesDatabase); | 53 TestLazyOpenUpgradesDatabase); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // version 2. | 96 // version 2. |
| 94 bool UpgradeVersion1To2(); | 97 bool UpgradeVersion1To2(); |
| 95 | 98 |
| 96 void Close(); | 99 void Close(); |
| 97 bool IsOpen() const { return db_.get() ? db_->is_open() : false; } | 100 bool IsOpen() const { return db_.get() ? db_->is_open() : false; } |
| 98 | 101 |
| 99 // Initialization code shared between the two constructors of this class. | 102 // Initialization code shared between the two constructors of this class. |
| 100 void Init(); | 103 void Init(); |
| 101 | 104 |
| 102 // Path to the database on disk. | 105 // Path to the database on disk. |
| 103 FilePath file_path_; | 106 const FilePath file_path_; |
| 104 scoped_ptr<sql::Connection> db_; | 107 scoped_ptr<sql::Connection> db_; |
| 105 bool failed_to_open_; | 108 bool failed_to_open_; |
| 106 bool tried_to_recreate_; | 109 bool tried_to_recreate_; |
| 107 bool known_to_be_empty_; | 110 bool known_to_be_empty_; |
| 108 }; | 111 }; |
| 109 | 112 |
| 110 } // namespace dom_storage | 113 } // namespace dom_storage |
| 111 | 114 |
| 112 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_DATABASE_H_ | 115 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_DATABASE_H_ |
| OLD | NEW |