/src/3rdparty/webkit/Source/WebCore/storage/IDBBackingStore.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 114 lines · 72 code · 18 blank · 24 comment · 0 complexity · 021d97874b42b73f108ac993121f799d MD5 · raw file

  1. /*
  2. * Copyright (C) 2011 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  15. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  18. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef IDBBackingStore_h
  26. #define IDBBackingStore_h
  27. #if ENABLE(INDEXED_DATABASE)
  28. #include "IDBCursor.h"
  29. #include "SQLiteDatabase.h"
  30. #include <wtf/PassRefPtr.h>
  31. #include <wtf/RefCounted.h>
  32. #include <wtf/RefPtr.h>
  33. #include <wtf/Vector.h>
  34. namespace WebCore {
  35. class IDBFactoryBackendImpl;
  36. class IDBKey;
  37. class IDBKeyRange;
  38. class SecurityOrigin;
  39. class IDBBackingStore : public RefCounted<IDBBackingStore> {
  40. public:
  41. virtual ~IDBBackingStore() {};
  42. virtual bool extractIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundId) = 0;
  43. virtual bool setIDBDatabaseMetaData(const String& name, const String& version, int64_t& rowId, bool invalidRowId) = 0;
  44. virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) = 0;
  45. virtual bool createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) = 0;
  46. virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId) = 0;
  47. class ObjectStoreRecordIdentifier : public RefCounted<ObjectStoreRecordIdentifier> {
  48. public:
  49. virtual bool isValid() const = 0;
  50. virtual ~ObjectStoreRecordIdentifier() {}
  51. };
  52. virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier() = 0;
  53. virtual String getObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&) = 0;
  54. virtual bool putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) = 0;
  55. virtual void clearObjectStore(int64_t databaseId, int64_t objectStoreId) = 0;
  56. virtual void deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) = 0;
  57. virtual double nextAutoIncrementNumber(int64_t databaseId, int64_t objectStoreId) = 0;
  58. virtual bool keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) = 0;
  59. class ObjectStoreRecordCallback {
  60. public:
  61. virtual bool callback(const ObjectStoreRecordIdentifier*, const String& value) = 0;
  62. virtual ~ObjectStoreRecordCallback() {};
  63. };
  64. virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) = 0;
  65. virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags) = 0;
  66. virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, int64_t& indexId) = 0;
  67. virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId) = 0;
  68. virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) = 0;
  69. virtual bool deleteIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) = 0;
  70. virtual String getObjectViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) = 0;
  71. virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) = 0;
  72. virtual bool keyExistsInIndex(int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey&) = 0;
  73. class Cursor : public RefCounted<Cursor> {
  74. public:
  75. virtual bool continueFunction(const IDBKey* = 0) = 0;
  76. virtual PassRefPtr<IDBKey> key() = 0;
  77. virtual PassRefPtr<IDBKey> primaryKey() = 0;
  78. virtual String value() = 0;
  79. virtual PassRefPtr<ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0;
  80. virtual int64_t indexDataId() = 0;
  81. virtual ~Cursor() {};
  82. };
  83. virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) = 0;
  84. virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) = 0;
  85. virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) = 0;
  86. class Transaction : public RefCounted<Transaction> {
  87. public:
  88. virtual void begin() = 0;
  89. virtual void commit() = 0;
  90. virtual void rollback() = 0;
  91. };
  92. virtual PassRefPtr<Transaction> createTransaction() = 0;
  93. };
  94. } // namespace WebCore
  95. #endif
  96. #endif // IDBBackingStore_h