| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 class DOMException; | 52 class DOMException; |
| 53 class ExceptionState; | 53 class ExceptionState; |
| 54 class ExecutionContext; | 54 class ExecutionContext; |
| 55 | 55 |
| 56 class MODULES_EXPORT IDBDatabase final | 56 class MODULES_EXPORT IDBDatabase final |
| 57 : public RefCountedGarbageCollectedEventTargetWithInlineData<IDBDatabase> | 57 : public RefCountedGarbageCollectedEventTargetWithInlineData<IDBDatabase> |
| 58 , public ActiveDOMObject { | 58 , public ActiveDOMObject { |
| 59 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(IDBDatabase); | 59 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(IDBDatabase); |
| 60 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase); | 60 USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase); |
| 61 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
| 62 public: | 62 public: |
| 63 static IDBDatabase* create(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, ID
BDatabaseCallbacks*); | 63 static IDBDatabase* create(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, ID
BDatabaseCallbacks*); |
| 64 ~IDBDatabase() override; | 64 ~IDBDatabase() override; |
| 65 DECLARE_VIRTUAL_TRACE(); | 65 DECLARE_VIRTUAL_TRACE(); |
| 66 | 66 |
| 67 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } | 67 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } |
| 68 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); | 68 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); |
| 69 void indexDeleted(int64_t objectStoreId, int64_t indexId); | 69 void indexDeleted(int64_t objectStoreId, int64_t indexId); |
| 70 void transactionCreated(IDBTransaction*); | 70 void transactionCreated(IDBTransaction*); |
| 71 void transactionFinished(const IDBTransaction*); | 71 void transactionFinished(const IDBTransaction*); |
| 72 | 72 |
| 73 // Implement the IDL | 73 // Implement the IDL |
| 74 const String& name() const { return m_metadata.name; } | 74 const String& name() const { return m_metadata.name; } |
| 75 void version(UnsignedLongLongOrString& result) const; | 75 void version(UnsignedLongLongOrString& result) const; |
| 76 PassRefPtrWillBeRawPtr<DOMStringList> objectStoreNames() const; | 76 RawPtr<DOMStringList> objectStoreNames() const; |
| 77 | 77 |
| 78 IDBObjectStore* createObjectStore(const String& name, const IDBObjectStorePa
rameters& options, ExceptionState& exceptionState) { return createObjectStore(na
me, IDBKeyPath(options.keyPath()), options.autoIncrement(), exceptionState); } | 78 IDBObjectStore* createObjectStore(const String& name, const IDBObjectStorePa
rameters& options, ExceptionState& exceptionState) { return createObjectStore(na
me, IDBKeyPath(options.keyPath()), options.autoIncrement(), exceptionState); } |
| 79 IDBTransaction* transaction(ScriptState*, const StringOrStringSequenceOrDOMS
tringList&, const String& mode, ExceptionState&); | 79 IDBTransaction* transaction(ScriptState*, const StringOrStringSequenceOrDOMS
tringList&, const String& mode, ExceptionState&); |
| 80 void deleteObjectStore(const String& name, ExceptionState&); | 80 void deleteObjectStore(const String& name, ExceptionState&); |
| 81 void close(); | 81 void close(); |
| 82 | 82 |
| 83 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); | 83 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); |
| 84 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 84 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
| 85 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 85 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 86 DEFINE_ATTRIBUTE_EVENT_LISTENER(versionchange); | 86 DEFINE_ATTRIBUTE_EVENT_LISTENER(versionchange); |
| 87 | 87 |
| 88 // IDBDatabaseCallbacks | 88 // IDBDatabaseCallbacks |
| 89 void onVersionChange(int64_t oldVersion, int64_t newVersion); | 89 void onVersionChange(int64_t oldVersion, int64_t newVersion); |
| 90 void onAbort(int64_t, DOMException*); | 90 void onAbort(int64_t, DOMException*); |
| 91 void onComplete(int64_t); | 91 void onComplete(int64_t); |
| 92 | 92 |
| 93 // ActiveDOMObject | 93 // ActiveDOMObject |
| 94 bool hasPendingActivity() const override; | 94 bool hasPendingActivity() const override; |
| 95 void stop() override; | 95 void stop() override; |
| 96 | 96 |
| 97 // EventTarget | 97 // EventTarget |
| 98 const AtomicString& interfaceName() const override; | 98 const AtomicString& interfaceName() const override; |
| 99 ExecutionContext* executionContext() const override; | 99 ExecutionContext* executionContext() const override; |
| 100 | 100 |
| 101 bool isClosePending() const { return m_closePending; } | 101 bool isClosePending() const { return m_closePending; } |
| 102 void forceClose(); | 102 void forceClose(); |
| 103 const IDBDatabaseMetadata& metadata() const { return m_metadata; } | 103 const IDBDatabaseMetadata& metadata() const { return m_metadata; } |
| 104 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); | 104 void enqueueEvent(RawPtr<Event>); |
| 105 | 105 |
| 106 int64_t findObjectStoreId(const String& name) const; | 106 int64_t findObjectStoreId(const String& name) const; |
| 107 bool containsObjectStore(const String& name) const | 107 bool containsObjectStore(const String& name) const |
| 108 { | 108 { |
| 109 return findObjectStoreId(name) != IDBObjectStoreMetadata::InvalidId; | 109 return findObjectStoreId(name) != IDBObjectStoreMetadata::InvalidId; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Will return nullptr if this database is stopped. | 112 // Will return nullptr if this database is stopped. |
| 113 WebIDBDatabase* backend() const { return m_backend.get(); } | 113 WebIDBDatabase* backend() const { return m_backend.get(); } |
| 114 | 114 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 127 static const char sourceDeletedErrorMessage[]; | 127 static const char sourceDeletedErrorMessage[]; |
| 128 static const char transactionFinishedErrorMessage[]; | 128 static const char transactionFinishedErrorMessage[]; |
| 129 static const char transactionInactiveErrorMessage[]; | 129 static const char transactionInactiveErrorMessage[]; |
| 130 static const char transactionReadOnlyErrorMessage[]; | 130 static const char transactionReadOnlyErrorMessage[]; |
| 131 static const char databaseClosedErrorMessage[]; | 131 static const char databaseClosedErrorMessage[]; |
| 132 | 132 |
| 133 static void recordApiCallsHistogram(IndexedDatabaseMethods); | 133 static void recordApiCallsHistogram(IndexedDatabaseMethods); |
| 134 | 134 |
| 135 protected: | 135 protected: |
| 136 // EventTarget | 136 // EventTarget |
| 137 bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>) override; | 137 bool dispatchEventInternal(RawPtr<Event>) override; |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 IDBDatabase(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, IDBDatabaseCallba
cks*); | 140 IDBDatabase(ExecutionContext*, PassOwnPtr<WebIDBDatabase>, IDBDatabaseCallba
cks*); |
| 141 | 141 |
| 142 IDBObjectStore* createObjectStore(const String& name, const IDBKeyPath&, boo
l autoIncrement, ExceptionState&); | 142 IDBObjectStore* createObjectStore(const String& name, const IDBKeyPath&, boo
l autoIncrement, ExceptionState&); |
| 143 void closeConnection(); | 143 void closeConnection(); |
| 144 | 144 |
| 145 IDBDatabaseMetadata m_metadata; | 145 IDBDatabaseMetadata m_metadata; |
| 146 OwnPtr<WebIDBDatabase> m_backend; | 146 OwnPtr<WebIDBDatabase> m_backend; |
| 147 Member<IDBTransaction> m_versionChangeTransaction; | 147 Member<IDBTransaction> m_versionChangeTransaction; |
| 148 HeapHashMap<int64_t, Member<IDBTransaction>> m_transactions; | 148 HeapHashMap<int64_t, Member<IDBTransaction>> m_transactions; |
| 149 | 149 |
| 150 bool m_closePending = false; | 150 bool m_closePending = false; |
| 151 bool m_contextStopped = false; | 151 bool m_contextStopped = false; |
| 152 | 152 |
| 153 // Keep track of the versionchange events waiting to be fired on this | 153 // Keep track of the versionchange events waiting to be fired on this |
| 154 // database so that we can cancel them if the database closes. | 154 // database so that we can cancel them if the database closes. |
| 155 WillBeHeapVector<RefPtrWillBeMember<Event>> m_enqueuedEvents; | 155 HeapVector<Member<Event>> m_enqueuedEvents; |
| 156 | 156 |
| 157 Member<IDBDatabaseCallbacks> m_databaseCallbacks; | 157 Member<IDBDatabaseCallbacks> m_databaseCallbacks; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 } // namespace blink | 160 } // namespace blink |
| 161 | 161 |
| 162 #endif // IDBDatabase_h | 162 #endif // IDBDatabase_h |
| OLD | NEW |