| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 bool* is_disk_full) = 0; | 36 bool* is_disk_full) = 0; |
| 37 virtual bool DestroyLevelDB(const base::FilePath& file_name) = 0; | 37 virtual bool DestroyLevelDB(const base::FilePath& file_name) = 0; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class CONTENT_EXPORT IndexedDBBackingStore | 40 class CONTENT_EXPORT IndexedDBBackingStore |
| 41 : public base::RefCounted<IndexedDBBackingStore> { | 41 : public base::RefCounted<IndexedDBBackingStore> { |
| 42 public: | 42 public: |
| 43 class CONTENT_EXPORT Transaction; | 43 class CONTENT_EXPORT Transaction; |
| 44 | 44 |
| 45 static scoped_refptr<IndexedDBBackingStore> Open( | 45 static scoped_refptr<IndexedDBBackingStore> Open( |
| 46 const string16& database_identifier, | 46 const std::string& origin_identifier, |
| 47 const base::FilePath& path_base, | 47 const base::FilePath& path_base, |
| 48 const string16& file_identifier, | 48 const std::string& file_identifier, |
| 49 WebKit::WebIDBCallbacks::DataLoss* data_loss); | 49 WebKit::WebIDBCallbacks::DataLoss* data_loss); |
| 50 |
| 50 static scoped_refptr<IndexedDBBackingStore> Open( | 51 static scoped_refptr<IndexedDBBackingStore> Open( |
| 51 const string16& database_identifier, | 52 const std::string& origin_identifier, |
| 52 const base::FilePath& path_base, | 53 const base::FilePath& path_base, |
| 53 const string16& file_identifier, | 54 const std::string& file_identifier, |
| 54 WebKit::WebIDBCallbacks::DataLoss* data_loss, | 55 WebKit::WebIDBCallbacks::DataLoss* data_loss, |
| 55 LevelDBFactory* factory); | 56 LevelDBFactory* factory); |
| 56 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( | 57 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( |
| 57 const string16& identifier); | 58 const std::string& file_identifier); |
| 58 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( | 59 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( |
| 59 const string16& identifier, | 60 const std::string& file_identifier, |
| 60 LevelDBFactory* factory); | 61 LevelDBFactory* factory); |
| 61 base::WeakPtr<IndexedDBBackingStore> GetWeakPtr() { | 62 base::WeakPtr<IndexedDBBackingStore> GetWeakPtr() { |
| 62 return weak_factory_.GetWeakPtr(); | 63 return weak_factory_.GetWeakPtr(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 virtual std::vector<string16> GetDatabaseNames(); | 66 virtual std::vector<string16> GetDatabaseNames(); |
| 66 virtual bool GetIDBDatabaseMetaData(const string16& name, | 67 virtual bool GetIDBDatabaseMetaData(const string16& name, |
| 67 IndexedDBDatabaseMetadata* metadata, | 68 IndexedDBDatabaseMetadata* metadata, |
| 68 bool* success) WARN_UNUSED_RESULT; | 69 bool* success) WARN_UNUSED_RESULT; |
| 69 virtual bool CreateIDBDatabaseMetaData(const string16& name, | 70 virtual bool CreateIDBDatabaseMetaData(const string16& name, |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 Transaction* transaction) { | 283 Transaction* transaction) { |
| 283 return transaction->transaction_; | 284 return transaction->transaction_; |
| 284 } | 285 } |
| 285 | 286 |
| 286 private: | 287 private: |
| 287 IndexedDBBackingStore* backing_store_; | 288 IndexedDBBackingStore* backing_store_; |
| 288 scoped_refptr<LevelDBTransaction> transaction_; | 289 scoped_refptr<LevelDBTransaction> transaction_; |
| 289 }; | 290 }; |
| 290 | 291 |
| 291 protected: | 292 protected: |
| 292 IndexedDBBackingStore(const string16& identifier, | 293 IndexedDBBackingStore(const std::string& identifier, |
| 293 scoped_ptr<LevelDBDatabase> db, | 294 scoped_ptr<LevelDBDatabase> db, |
| 294 scoped_ptr<LevelDBComparator> comparator); | 295 scoped_ptr<LevelDBComparator> comparator); |
| 295 virtual ~IndexedDBBackingStore(); | 296 virtual ~IndexedDBBackingStore(); |
| 296 friend class base::RefCounted<IndexedDBBackingStore>; | 297 friend class base::RefCounted<IndexedDBBackingStore>; |
| 297 | 298 |
| 298 private: | 299 private: |
| 299 static scoped_refptr<IndexedDBBackingStore> Create( | 300 static scoped_refptr<IndexedDBBackingStore> Create( |
| 300 const string16& identifier, | 301 const std::string& identifier, |
| 301 scoped_ptr<LevelDBDatabase> db, | 302 scoped_ptr<LevelDBDatabase> db, |
| 302 scoped_ptr<LevelDBComparator> comparator); | 303 scoped_ptr<LevelDBComparator> comparator); |
| 303 | 304 |
| 304 bool FindKeyInIndex(IndexedDBBackingStore::Transaction* transaction, | 305 bool FindKeyInIndex(IndexedDBBackingStore::Transaction* transaction, |
| 305 int64 database_id, | 306 int64 database_id, |
| 306 int64 object_store_id, | 307 int64 object_store_id, |
| 307 int64 index_id, | 308 int64 index_id, |
| 308 const IndexedDBKey& key, | 309 const IndexedDBKey& key, |
| 309 std::vector<char>* found_encoded_primary_key, | 310 std::vector<char>* found_encoded_primary_key, |
| 310 bool* found); | 311 bool* found); |
| 311 bool GetIndexes(int64 database_id, | 312 bool GetIndexes(int64 database_id, |
| 312 int64 object_store_id, | 313 int64 object_store_id, |
| 313 IndexedDBObjectStoreMetadata::IndexMap* map) | 314 IndexedDBObjectStoreMetadata::IndexMap* map) |
| 314 WARN_UNUSED_RESULT; | 315 WARN_UNUSED_RESULT; |
| 315 | 316 |
| 316 string16 identifier_; | 317 std::string identifier_; |
| 317 | 318 |
| 318 scoped_ptr<LevelDBDatabase> db_; | 319 scoped_ptr<LevelDBDatabase> db_; |
| 319 scoped_ptr<LevelDBComparator> comparator_; | 320 scoped_ptr<LevelDBComparator> comparator_; |
| 320 base::WeakPtrFactory<IndexedDBBackingStore> weak_factory_; | 321 base::WeakPtrFactory<IndexedDBBackingStore> weak_factory_; |
| 321 }; | 322 }; |
| 322 | 323 |
| 323 } // namespace content | 324 } // namespace content |
| 324 | 325 |
| 325 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 326 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
| OLD | NEW |