| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 class IDBBackingStore; | 38 class IDBBackingStore; |
| 39 class IDBDatabase; | 39 class IDBDatabase; |
| 40 class IDBFactoryBackendImpl; | 40 class IDBFactoryBackendImpl; |
| 41 class IDBTransactionBackendImpl; | 41 class IDBTransactionBackendImpl; |
| 42 class IDBTransactionCoordinator; | 42 class IDBTransactionCoordinator; |
| 43 | 43 |
| 44 class IDBDatabaseBackendImpl : public IDBDatabaseBackendInterface { | 44 class IDBDatabaseBackendImpl : public IDBDatabaseBackendInterface { |
| 45 public: | 45 public: |
| 46 static PassRefPtr<IDBDatabaseBackendImpl> create(const String& name, IDBBack
ingStore* database, IDBFactoryBackendImpl*, const String& uniqueIdentifier); | 46 static IDBDatabaseBackendImpl* create(const String& name, IDBBackingStore* d
atabase, IDBFactoryBackendImpl*, const String& uniqueIdentifier); |
| 47 virtual ~IDBDatabaseBackendImpl(); | 47 virtual ~IDBDatabaseBackendImpl(); |
| 48 | 48 |
| 49 PassRefPtr<IDBBackingStore> backingStore() const; | 49 PassRefPtr<IDBBackingStore> backingStore() const; |
| 50 | 50 |
| 51 static const int64_t InvalidId = 0; | 51 static const int64_t InvalidId = 0; |
| 52 int64_t id() const { return m_metadata.id; } | 52 int64_t id() const { return m_metadata.id; } |
| 53 void addObjectStore(const IDBObjectStoreMetadata&, int64_t newMaxObjectStore
Id); | 53 void addObjectStore(const IDBObjectStoreMetadata&, int64_t newMaxObjectStore
Id); |
| 54 void removeObjectStore(int64_t objectStoreId); | 54 void removeObjectStore(int64_t objectStoreId); |
| 55 void addIndex(int64_t objectStoreId, const IDBIndexMetadata&, int64_t newMax
IndexId); | 55 void addIndex(int64_t objectStoreId, const IDBIndexMetadata&, int64_t newMax
IndexId); |
| 56 void removeIndex(int64_t objectStoreId, int64_t indexId); | 56 void removeIndex(int64_t objectStoreId, int64_t indexId); |
| 57 | 57 |
| 58 void openConnection(PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallback
s>, int64_t transactionId, int64_t version); | 58 void openConnection(PassRefPtr<IDBCallbacks>, IDBDatabaseCallbacks*, int64_t
transactionId, int64_t version); |
| 59 void deleteDatabase(PassRefPtr<IDBCallbacks>); | 59 void deleteDatabase(PassRefPtr<IDBCallbacks>); |
| 60 const IDBDatabaseMetadata& metadata() const { return m_metadata; } | 60 const IDBDatabaseMetadata& metadata() const { return m_metadata; } |
| 61 | 61 |
| 62 // IDBDatabaseBackendInterface | 62 // IDBDatabaseBackendInterface |
| 63 virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId,
const String& name, const IDBKeyPath&, bool autoIncrement); | 63 virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId,
const String& name, const IDBKeyPath&, bool autoIncrement); |
| 64 virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
; | 64 virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
; |
| 65 virtual void createTransaction(int64_t transactionId, PassRefPtr<IDBDatabase
Callbacks>, const Vector<int64_t>& objectStoreIds, unsigned short mode); | 65 virtual void createTransaction(int64_t transactionId, IDBDatabaseCallbacks*,
const Vector<int64_t>& objectStoreIds, unsigned short mode); |
| 66 virtual void close(PassRefPtr<IDBDatabaseCallbacks>); | 66 virtual void close(IDBDatabaseCallbacks*); |
| 67 | 67 |
| 68 virtual void commit(int64_t transactionId); | 68 virtual void commit(int64_t transactionId); |
| 69 virtual void abort(int64_t transactionId); | 69 virtual void abort(int64_t transactionId); |
| 70 virtual void abort(int64_t transactionId, PassRefPtr<IDBDatabaseError>); | 70 virtual void abort(int64_t transactionId, PassRefPtr<IDBDatabaseError>); |
| 71 | 71 |
| 72 virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry)
; | 72 virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry)
; |
| 73 virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId); | 73 virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64
_t indexId); |
| 74 | 74 |
| 75 IDBTransactionCoordinator* transactionCoordinator() const { return m_transac
tionCoordinator.get(); } | 75 IDBTransactionCoordinator* transactionCoordinator() const { return m_transac
tionCoordinator.get(); } |
| 76 void transactionStarted(PassRefPtr<IDBTransactionBackendImpl>); | 76 void transactionStarted(PassRefPtr<IDBTransactionBackendImpl>); |
| 77 void transactionFinished(PassRefPtr<IDBTransactionBackendImpl>); | 77 void transactionFinished(PassRefPtr<IDBTransactionBackendImpl>); |
| 78 void transactionFinishedAndCompleteFired(PassRefPtr<IDBTransactionBackendImp
l>); | 78 void transactionFinishedAndCompleteFired(PassRefPtr<IDBTransactionBackendImp
l>); |
| 79 void transactionFinishedAndAbortFired(PassRefPtr<IDBTransactionBackendImpl>)
; | 79 void transactionFinishedAndAbortFired(PassRefPtr<IDBTransactionBackendImpl>)
; |
| 80 | 80 |
| 81 virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t index
Id, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) OVERRIDE; | 81 virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t index
Id, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) OVERRIDE; |
| 82 virtual void put(int64_t transactionId, int64_t objectStoreId, PassRefPtr<Sh
aredBuffer> value, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const
Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE; | 82 virtual void put(int64_t transactionId, int64_t objectStoreId, PassRefPtr<Sh
aredBuffer> value, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const
Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE; |
| 83 virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, Pass
RefPtr<IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<Inde
xKeys>&) OVERRIDE; | 83 virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, Pass
RefPtr<IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<Inde
xKeys>&) OVERRIDE; |
| 84 virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, c
onst Vector<int64_t>& indexIds) OVERRIDE; | 84 virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, c
onst Vector<int64_t>& indexIds) OVERRIDE; |
| 85 virtual void openCursor(int64_t transactionId, int64_t objectStoreId, int64_
t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorDirection, bool keyOnly, Ta
skType, PassRefPtr<IDBCallbacks>) OVERRIDE; | 85 virtual void openCursor(int64_t transactionId, int64_t objectStoreId, int64_
t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorDirection, bool keyOnly, Ta
skType, PassRefPtr<IDBCallbacks>) OVERRIDE; |
| 86 virtual void count(int64_t transactionId, int64_t objectStoreId, int64_t ind
exId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE; | 86 virtual void count(int64_t transactionId, int64_t objectStoreId, int64_t ind
exId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE; |
| 87 virtual void deleteRange(int64_t transactionId, int64_t objectStoreId, PassR
efPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE; | 87 virtual void deleteRange(int64_t transactionId, int64_t objectStoreId, PassR
efPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE; |
| 88 virtual void clear(int64_t transactionId, int64_t objectStoreId, PassRefPtr<
IDBCallbacks>) OVERRIDE; | 88 virtual void clear(int64_t transactionId, int64_t objectStoreId, PassRefPtr<
IDBCallbacks>) OVERRIDE; |
| 89 | 89 |
| 90 virtual void trace(Visitor*) const; |
| 91 |
| 90 private: | 92 private: |
| 91 IDBDatabaseBackendImpl(const String& name, IDBBackingStore* database, IDBFac
toryBackendImpl*, const String& uniqueIdentifier); | 93 IDBDatabaseBackendImpl(const String& name, IDBBackingStore* database, IDBFac
toryBackendImpl*, const String& uniqueIdentifier); |
| 92 | 94 |
| 93 bool openInternal(); | 95 bool openInternal(); |
| 94 void runIntVersionChangeTransaction(PassRefPtr<IDBCallbacks>, PassRefPtr<IDB
DatabaseCallbacks>, int64_t transactionId, int64_t requestedVersion); | 96 void runIntVersionChangeTransaction(PassRefPtr<IDBCallbacks>, IDBDatabaseCal
lbacks*, int64_t transactionId, int64_t requestedVersion); |
| 95 size_t connectionCount(); | 97 size_t connectionCount(); |
| 96 void processPendingCalls(); | 98 void processPendingCalls(); |
| 97 | 99 |
| 98 bool isDeleteDatabaseBlocked(); | 100 bool isDeleteDatabaseBlocked(); |
| 99 void deleteDatabaseFinal(PassRefPtr<IDBCallbacks>); | 101 void deleteDatabaseFinal(PassRefPtr<IDBCallbacks>); |
| 100 | 102 |
| 101 class VersionChangeOperation; | 103 class VersionChangeOperation; |
| 102 | 104 |
| 103 // When a "versionchange" transaction aborts, these restore the back-end obj
ect hierarchy. | 105 // When a "versionchange" transaction aborts, these restore the back-end obj
ect hierarchy. |
| 104 class VersionChangeAbortOperation; | 106 class VersionChangeAbortOperation; |
| 105 | 107 |
| 106 RefPtr<IDBBackingStore> m_backingStore; | 108 RefPtr<IDBBackingStore> m_backingStore; |
| 107 IDBDatabaseMetadata m_metadata; | 109 IDBDatabaseMetadata m_metadata; |
| 108 | 110 |
| 109 String m_identifier; | 111 String m_identifier; |
| 110 // This might not need to be a RefPtr since the factory's lifetime is that o
f the page group, but it's better to be conservitive than sorry. | 112 // This might not need to be a RefPtr since the factory's lifetime is that o
f the page group, but it's better to be conservitive than sorry. |
| 111 // FIXME(oilpan): Move IDBDatabaseBackendInterface to the heap and use a Mem
ber. | 113 Member<IDBFactoryBackendImpl> m_factory; |
| 112 Persistent<IDBFactoryBackendImpl> m_factory; | |
| 113 | 114 |
| 114 OwnPtr<IDBTransactionCoordinator> m_transactionCoordinator; | 115 OwnPtr<IDBTransactionCoordinator> m_transactionCoordinator; |
| 115 RefPtr<IDBTransactionBackendImpl> m_runningVersionChangeTransaction; | 116 RefPtr<IDBTransactionBackendImpl> m_runningVersionChangeTransaction; |
| 116 | 117 |
| 117 typedef HashMap<int64_t, IDBTransactionBackendImpl*> TransactionMap; | 118 typedef HashMap<int64_t, IDBTransactionBackendImpl*> TransactionMap; |
| 118 TransactionMap m_transactions; | 119 TransactionMap m_transactions; |
| 119 | 120 |
| 120 class PendingOpenCall; | 121 class PendingOpenCall; |
| 121 Deque<OwnPtr<PendingOpenCall> > m_pendingOpenCalls; | 122 Deque<OwnPtr<PendingOpenCall> > m_pendingOpenCalls; |
| 122 OwnPtr<PendingOpenCall> m_pendingSecondHalfOpen; | 123 OwnPtr<PendingOpenCall> m_pendingSecondHalfOpen; |
| 123 | 124 |
| 124 class PendingDeleteCall; | 125 class PendingDeleteCall; |
| 125 Deque<OwnPtr<PendingDeleteCall> > m_pendingDeleteCalls; | 126 Deque<OwnPtr<PendingDeleteCall> > m_pendingDeleteCalls; |
| 126 | 127 |
| 127 typedef ListHashSet<RefPtr<IDBDatabaseCallbacks> > DatabaseCallbacksSet; | 128 typedef ListHashSet<Member<IDBDatabaseCallbacks> > DatabaseCallbacksSet; |
| 128 DatabaseCallbacksSet m_databaseCallbacksSet; | 129 DatabaseCallbacksSet m_databaseCallbacksSet; |
| 129 | 130 |
| 130 bool m_closingConnection; | 131 bool m_closingConnection; |
| 131 }; | 132 }; |
| 132 | 133 |
| 133 } // namespace WebCore | 134 } // namespace WebCore |
| 134 | 135 |
| 135 #endif // IDBDatabaseBackendImpl_h | 136 #endif // IDBDatabaseBackendImpl_h |
| OLD | NEW |