diff options
Diffstat (limited to 'Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h')
-rw-r--r-- | Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h b/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h index 86b1a0fbb..a15a1dc34 100644 --- a/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h +++ b/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h @@ -1,72 +1,74 @@ /* - * Copyright (C) 2012 Google Inc. All rights reserved. + * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef IDBOpenDBRequest_h -#define IDBOpenDBRequest_h +#pragma once #if ENABLE(INDEXED_DATABASE) +#include "IDBDatabaseIdentifier.h" #include "IDBRequest.h" -#include "IndexedDB.h" namespace WebCore { -class IDBDatabaseCallbacks; +class IDBResultData; -class IDBOpenDBRequest : public IDBRequest { +class IDBOpenDBRequest final : public IDBRequest { public: - static PassRefPtr<IDBOpenDBRequest> create(ScriptExecutionContext*, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, uint64_t version, IndexedDB::VersionNullness); + static Ref<IDBOpenDBRequest> createDeleteRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBDatabaseIdentifier&); + static Ref<IDBOpenDBRequest> createOpenRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBDatabaseIdentifier&, uint64_t version); + virtual ~IDBOpenDBRequest(); + + const IDBDatabaseIdentifier& databaseIdentifier() const { return m_databaseIdentifier; } + uint64_t version() const { return m_version; } + + void requestCompleted(const IDBResultData&); + void requestBlocked(uint64_t oldVersion, uint64_t newVersion); - using IDBRequest::onSuccess; + void versionChangeTransactionDidFinish(); + void fireSuccessAfterVersionChangeCommit(); + void fireErrorAfterVersionChangeCompletion(); - virtual void onBlocked(uint64_t existingVersion) override; - virtual void onUpgradeNeeded(uint64_t oldVersion, PassRefPtr<IDBDatabaseBackend>, const IDBDatabaseMetadata&) override; - virtual void onSuccess(PassRefPtr<IDBDatabaseBackend>, const IDBDatabaseMetadata&) override; +private: + IDBOpenDBRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType); - // EventTarget - virtual EventTargetInterface eventTargetInterface() const; - virtual bool dispatchEvent(PassRefPtr<Event>) override; + bool dispatchEvent(Event&) final; - DEFINE_ATTRIBUTE_EVENT_LISTENER(blocked); - DEFINE_ATTRIBUTE_EVENT_LISTENER(upgradeneeded); + void cancelForStop() final; -protected: - virtual bool shouldEnqueueEvent() const override; + void onError(const IDBResultData&); + void onSuccess(const IDBResultData&); + void onUpgradeNeeded(const IDBResultData&); + void onDeleteDatabaseSuccess(const IDBResultData&); -private: - IDBOpenDBRequest(ScriptExecutionContext*, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, uint64_t version, IndexedDB::VersionNullness); + bool isOpenDBRequest() const final { return true; } - RefPtr<IDBDatabaseCallbacks> m_databaseCallbacks; - const int64_t m_transactionId; - uint64_t m_version; - IndexedDB::VersionNullness m_versionNullness; + IDBDatabaseIdentifier m_databaseIdentifier; + uint64_t m_version { 0 }; }; } // namespace WebCore #endif // ENABLE(INDEXED_DATABASE) - -#endif // IDBOpenDBRequest_h |