| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ |
| 6 #define CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/common/dom_storage/dom_storage_types.h" | 19 #include "content/common/dom_storage/dom_storage_types.h" |
| 20 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 20 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
| 21 | 21 |
| 22 class GURL; | 22 class GURL; |
| 23 | 23 |
| 24 namespace leveldb { | 24 namespace leveldb { |
| 25 class DB; | 25 class DB; |
| 26 struct ReadOptions; | 26 struct ReadOptions; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 // Helper functions for creating the keys needed for the schema. | 185 // Helper functions for creating the keys needed for the schema. |
| 186 static std::string NamespaceStartKey(const std::string& namespace_id); | 186 static std::string NamespaceStartKey(const std::string& namespace_id); |
| 187 static std::string NamespaceKey(const std::string& namespace_id, | 187 static std::string NamespaceKey(const std::string& namespace_id, |
| 188 const std::string& origin); | 188 const std::string& origin); |
| 189 static const char* NamespacePrefix(); | 189 static const char* NamespacePrefix(); |
| 190 static std::string MapRefCountKey(const std::string& map_id); | 190 static std::string MapRefCountKey(const std::string& map_id); |
| 191 static std::string MapKey(const std::string& map_id, const std::string& key); | 191 static std::string MapKey(const std::string& map_id, const std::string& key); |
| 192 static const char* NextMapIdKey(); | 192 static const char* NextMapIdKey(); |
| 193 | 193 |
| 194 scoped_ptr<leveldb::DB> db_; | 194 std::unique_ptr<leveldb::DB> db_; |
| 195 base::FilePath file_path_; | 195 base::FilePath file_path_; |
| 196 | 196 |
| 197 // For protecting the database opening code. Also guards the variables below. | 197 // For protecting the database opening code. Also guards the variables below. |
| 198 base::Lock db_lock_; | 198 base::Lock db_lock_; |
| 199 | 199 |
| 200 // True if a database error has occurred (e.g., cannot read data). | 200 // True if a database error has occurred (e.g., cannot read data). |
| 201 bool db_error_; | 201 bool db_error_; |
| 202 // True if the database is in an inconsistent state. | 202 // True if the database is in an inconsistent state. |
| 203 bool is_inconsistent_; | 203 bool is_inconsistent_; |
| 204 // True if the database is in a failed or inconsistent state, and we have | 204 // True if the database is in a failed or inconsistent state, and we have |
| 205 // already deleted it (as an attempt to recover later). | 205 // already deleted it (as an attempt to recover later). |
| 206 bool invalid_db_deleted_; | 206 bool invalid_db_deleted_; |
| 207 | 207 |
| 208 // The number of database operations in progress. We need this so that we can | 208 // The number of database operations in progress. We need this so that we can |
| 209 // delete an inconsistent database at the right moment. | 209 // delete an inconsistent database at the right moment. |
| 210 int operation_count_; | 210 int operation_count_; |
| 211 | 211 |
| 212 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); | 212 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 } // namespace content | 215 } // namespace content |
| 216 | 216 |
| 217 #endif // CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ | 217 #endif // CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ |
| OLD | NEW |