OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 blink::WebIDBDataLoss* data_loss, | 71 blink::WebIDBDataLoss* data_loss, |
72 std::string* data_loss_message, | 72 std::string* data_loss_message, |
73 bool* disk_full, | 73 bool* disk_full, |
74 LevelDBFactory* factory); | 74 LevelDBFactory* factory); |
75 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( | 75 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( |
76 const GURL& origin_url); | 76 const GURL& origin_url); |
77 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( | 77 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( |
78 const GURL& origin_url, | 78 const GURL& origin_url, |
79 LevelDBFactory* factory); | 79 LevelDBFactory* factory); |
80 | 80 |
| 81 // Compact is public for testing. |
| 82 virtual void Compact(); |
81 virtual std::vector<base::string16> GetDatabaseNames(); | 83 virtual std::vector<base::string16> GetDatabaseNames(); |
82 virtual leveldb::Status GetIDBDatabaseMetaData( | 84 virtual leveldb::Status GetIDBDatabaseMetaData( |
83 const base::string16& name, | 85 const base::string16& name, |
84 IndexedDBDatabaseMetadata* metadata, | 86 IndexedDBDatabaseMetadata* metadata, |
85 bool* success) WARN_UNUSED_RESULT; | 87 bool* success) WARN_UNUSED_RESULT; |
86 virtual leveldb::Status CreateIDBDatabaseMetaData( | 88 virtual leveldb::Status CreateIDBDatabaseMetaData( |
87 const base::string16& name, | 89 const base::string16& name, |
88 const base::string16& version, | 90 const base::string16& version, |
89 int64 int_version, | 91 int64 int_version, |
90 int64* row_id); | 92 int64* row_id); |
91 virtual bool UpdateIDBDatabaseIntVersion( | 93 virtual bool UpdateIDBDatabaseIntVersion( |
92 IndexedDBBackingStore::Transaction* transaction, | 94 IndexedDBBackingStore::Transaction* transaction, |
93 int64 row_id, | 95 int64 row_id, |
94 int64 int_version); | 96 int64 int_version); |
95 virtual leveldb::Status DeleteDatabase(const base::string16& name); | 97 virtual leveldb::Status DeleteDatabase(const base::string16& name); |
96 | 98 |
| 99 // Assumes caller has already closed the backing store. |
| 100 static leveldb::Status DestroyBackingStore(const base::FilePath& path_base, |
| 101 const GURL& origin_url); |
| 102 static bool RecordCorruptionInfo(const base::FilePath& path_base, |
| 103 const GURL& origin_url, |
| 104 const std::string& message); |
97 leveldb::Status GetObjectStores( | 105 leveldb::Status GetObjectStores( |
98 int64 database_id, | 106 int64 database_id, |
99 IndexedDBDatabaseMetadata::ObjectStoreMap* map) WARN_UNUSED_RESULT; | 107 IndexedDBDatabaseMetadata::ObjectStoreMap* map) WARN_UNUSED_RESULT; |
100 virtual leveldb::Status CreateObjectStore( | 108 virtual leveldb::Status CreateObjectStore( |
101 IndexedDBBackingStore::Transaction* transaction, | 109 IndexedDBBackingStore::Transaction* transaction, |
102 int64 database_id, | 110 int64 database_id, |
103 int64 object_store_id, | 111 int64 object_store_id, |
104 const base::string16& name, | 112 const base::string16& name, |
105 const IndexedDBKeyPath& key_path, | 113 const IndexedDBKeyPath& key_path, |
106 bool auto_increment); | 114 bool auto_increment); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 scoped_ptr<LevelDBDatabase> db, | 326 scoped_ptr<LevelDBDatabase> db, |
319 scoped_ptr<LevelDBComparator> comparator); | 327 scoped_ptr<LevelDBComparator> comparator); |
320 virtual ~IndexedDBBackingStore(); | 328 virtual ~IndexedDBBackingStore(); |
321 friend class base::RefCounted<IndexedDBBackingStore>; | 329 friend class base::RefCounted<IndexedDBBackingStore>; |
322 | 330 |
323 private: | 331 private: |
324 static scoped_refptr<IndexedDBBackingStore> Create( | 332 static scoped_refptr<IndexedDBBackingStore> Create( |
325 const GURL& origin_url, | 333 const GURL& origin_url, |
326 scoped_ptr<LevelDBDatabase> db, | 334 scoped_ptr<LevelDBDatabase> db, |
327 scoped_ptr<LevelDBComparator> comparator); | 335 scoped_ptr<LevelDBComparator> comparator); |
| 336 static bool ReadCorruptionInfo(const base::FilePath& path_base, |
| 337 const GURL& origin_url, |
| 338 std::string& message); |
328 | 339 |
329 leveldb::Status FindKeyInIndex( | 340 leveldb::Status FindKeyInIndex( |
330 IndexedDBBackingStore::Transaction* transaction, | 341 IndexedDBBackingStore::Transaction* transaction, |
331 int64 database_id, | 342 int64 database_id, |
332 int64 object_store_id, | 343 int64 object_store_id, |
333 int64 index_id, | 344 int64 index_id, |
334 const IndexedDBKey& key, | 345 const IndexedDBKey& key, |
335 std::string* found_encoded_primary_key, | 346 std::string* found_encoded_primary_key, |
336 bool* found); | 347 bool* found); |
337 leveldb::Status GetIndexes(int64 database_id, | 348 leveldb::Status GetIndexes(int64 database_id, |
(...skipping 12 matching lines...) Expand all Loading... |
350 const std::string origin_identifier_; | 361 const std::string origin_identifier_; |
351 | 362 |
352 scoped_ptr<LevelDBDatabase> db_; | 363 scoped_ptr<LevelDBDatabase> db_; |
353 scoped_ptr<LevelDBComparator> comparator_; | 364 scoped_ptr<LevelDBComparator> comparator_; |
354 base::OneShotTimer<IndexedDBBackingStore> close_timer_; | 365 base::OneShotTimer<IndexedDBBackingStore> close_timer_; |
355 }; | 366 }; |
356 | 367 |
357 } // namespace content | 368 } // namespace content |
358 | 369 |
359 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 370 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
OLD | NEW |