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