LayoutTests/ChangeLog

 12015-09-30 Brady Eidson <beidson@apple.com>
 2
 3 Add UniqueIDBDatabase object, IDBBackingStore objects, and a database operation thread.
 4 https://bugs.webkit.org/show_bug.cgi?id=149678
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * storage/indexeddb/modern/opendatabase-request-event-expected.txt: Added.
 9 * storage/indexeddb/modern/opendatabase-request-event.html: Added.
 10
1112015-09-30 Keith Miller <keith_miller@apple.com>
212
313 [ES6] Add TypedArray.prototype functionality.

LayoutTests/storage/indexeddb/modern/opendatabase-request-event-expected.txt

 1ALERT: [object IDBOpenDBRequest]
 2ALERT: error [object Event]
 3ALERT: Done
 4This test calls open on window.indexedDB in various ways, verifying that IDBOpenDBRequest objects are returned when expected and exceptions are thrown when expected.

LayoutTests/storage/indexeddb/modern/opendatabase-request-event.html

 1This test calls open on window.indexedDB in various ways, verifying that IDBOpenDBRequest objects are returned when expected and exceptions are thrown when expected.
 2<script>
 3
 4if (window.testRunner) {
 5 testRunner.waitUntilDone();
 6 testRunner.dumpAsText();
 7}
 8
 9function done()
 10{
 11 alert("Done");
 12 if (window.testRunner)
 13 testRunner.notifyDone();
 14}
 15
 16var request = window.indexedDB.open("TestDatabase");
 17alert(request);
 18
 19request.onsuccess = function()
 20{
 21 alert("success");
 22 done();
 23}
 24request.onerror = function(e)
 25{
 26 alert("error " + e);
 27 done();
 28}
 29</script>

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
898898
899899 Modules/indexeddb/server/IDBConnectionToClient.cpp
900900 Modules/indexeddb/server/IDBServer.cpp
 901 Modules/indexeddb/server/IDBServerOperation.cpp
 902 Modules/indexeddb/server/MemoryIDBBackingStore.cpp
 903 Modules/indexeddb/server/UniqueIDBDatabase.cpp
901904
 905 Modules/indexeddb/shared/IDBDatabaseInfo.cpp
902906 Modules/indexeddb/shared/IDBError.cpp
903907 Modules/indexeddb/shared/IDBRequestData.cpp
904908 Modules/indexeddb/shared/IDBRequestIdentifier.cpp

Source/WebCore/ChangeLog

 12015-09-30 Brady Eidson <beidson@apple.com>
 2
 3 Add UniqueIDBDatabase object, IDBBackingStore objects, and a database operation thread.
 4 https://bugs.webkit.org/show_bug.cgi?id=149678
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Test: storage/indexeddb/modern/opendatabase-request-event.html
 9
 10 - UniqueIDBDatabase represents a specific IDB database instance that can have multiple
 11 connections to it.
 12 - IDBBackingStore is an abstract representation of a unique database's backing store,
 13 and has a concrete in-memory implementation for now.
 14 - The database thread exists on IDBServer and is for offloading actual database I/O from
 15 the main thread.
 16
 17 * CMakeLists.txt:
 18
 19 * Modules/indexeddb/IDBDatabaseIdentifier.cpp:
 20 (WebCore::IDBDatabaseIdentifier::isolatedCopy):
 21 * Modules/indexeddb/IDBDatabaseIdentifier.h:
 22
 23 * Modules/indexeddb/client/IDBConnectionToServer.cpp:
 24 (WebCore::IDBClient::IDBConnectionToServer::openDatabase):
 25 (WebCore::IDBClient::IDBConnectionToServer::didOpenDatabase):
 26 * Modules/indexeddb/client/IDBConnectionToServer.h:
 27 * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
 28
 29 * Modules/indexeddb/client/IDBFactoryImpl.cpp:
 30 (WebCore::IDBClient::IDBFactory::openInternal):
 31
 32 * Modules/indexeddb/server/IDBBackingStore.h: Copied from Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h.
 33 (WebCore::IDBServer::IDBBackingStore::~IDBBackingStore):
 34
 35 * Modules/indexeddb/server/IDBConnectionToClient.cpp:
 36 (WebCore::IDBServer::IDBConnectionToClient::didOpenDatabase):
 37 * Modules/indexeddb/server/IDBConnectionToClient.h:
 38 * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
 39
 40 * Modules/indexeddb/server/IDBServer.cpp:
 41 (WebCore::IDBServer::IDBServer::IDBServer):
 42 (WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase):
 43 (WebCore::IDBServer::IDBServer::createBackingStore):
 44 (WebCore::IDBServer::IDBServer::openDatabase):
 45 (WebCore::IDBServer::IDBServer::deleteDatabase):
 46 (WebCore::IDBServer::IDBServer::postDatabaseTask):
 47 (WebCore::IDBServer::IDBServer::postDatabaseTaskReply):
 48 (WebCore::IDBServer::IDBServer::databaseThreadEntry):
 49 (WebCore::IDBServer::IDBServer::databaseRunLoop):
 50 (WebCore::IDBServer::IDBServer::handleTaskRepliesOnMainThread):
 51 * Modules/indexeddb/server/IDBServer.h:
 52
 53 * Modules/indexeddb/server/IDBServerOperation.cpp: Copied from Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h.
 54 (WebCore::IDBServer::IDBServerOperation::create):
 55 (WebCore::IDBServer::IDBServerOperation::IDBServerOperation):
 56 * Modules/indexeddb/server/IDBServerOperation.h: Copied from Source/WebCore/Modules/indexeddb/server/IDBServer.h.
 57 (WebCore::IDBServer::IDBServerOperation::connection):
 58 (WebCore::IDBServer::IDBServerOperation::requestData):
 59
 60 * Modules/indexeddb/server/MemoryIDBBackingStore.cpp: Copied from Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp.
 61 (WebCore::IDBServer::MemoryIDBBackingStore::create):
 62 (WebCore::IDBServer::MemoryIDBBackingStore::MemoryIDBBackingStore):
 63 (WebCore::IDBServer::MemoryIDBBackingStore::~MemoryIDBBackingStore):
 64 (WebCore::IDBServer::MemoryIDBBackingStore::getOrEstablishDatabaseInfo):
 65 * Modules/indexeddb/server/MemoryIDBBackingStore.h: Copied from Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h.
 66
 67 * Modules/indexeddb/server/UniqueIDBDatabase.cpp: Added.
 68 (WebCore::IDBServer::UniqueIDBDatabase::UniqueIDBDatabase):
 69 (WebCore::IDBServer::UniqueIDBDatabase::openDatabaseConnection):
 70 (WebCore::IDBServer::UniqueIDBDatabase::handleOpenDatabaseOperations):
 71 (WebCore::IDBServer::UniqueIDBDatabase::openBackingStore):
 72 (WebCore::IDBServer::UniqueIDBDatabase::didOpenBackingStore):
 73 * Modules/indexeddb/server/UniqueIDBDatabase.h: Copied from Source/WebCore/Modules/indexeddb/server/IDBServer.h.
 74 (WebCore::IDBServer::UniqueIDBDatabase::create):
 75
 76 * Modules/indexeddb/shared/IDBDatabaseInfo.cpp: Copied from Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h.
 77 (WebCore::IDBDatabaseInfo::IDBDatabaseInfo):
 78 (WebCore::IDBDatabaseInfo::isolatedCopy):
 79 * Modules/indexeddb/shared/IDBDatabaseInfo.h: Copied from Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h.
 80 (WebCore::IDBDatabaseInfo::IDBDatabaseInfo):
 81
 82 * Modules/indexeddb/shared/InProcessIDBServer.cpp:
 83 (WebCore::InProcessIDBServer::didDeleteDatabase):
 84 (WebCore::InProcessIDBServer::openDatabase):
 85 (WebCore::InProcessIDBServer::didOpenDatabase):
 86 * Modules/indexeddb/shared/InProcessIDBServer.h:
 87
 88 * WebCore.xcodeproj/project.pbxproj:
 89
 90 * platform/CrossThreadCopier.cpp:
 91 (WebCore::IDBDatabaseInfo>::copy):
 92 (WebCore::IDBDatabaseIdentifier>::copy):
 93 * platform/CrossThreadCopier.h:
 94
1952015-09-30 Chris Dumez <cdumez@apple.com>
296
397 Unreviewed, roll out r188331: "NetworkProcess: DNS prefetch happens in the Web Process"

Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp

@@IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, const S
4444 ASSERT(!databaseName.isNull());
4545}
4646
 47IDBDatabaseIdentifier IDBDatabaseIdentifier::isolatedCopy() const
 48{
 49 IDBDatabaseIdentifier identifier;
 50
 51 identifier.m_databaseName = m_databaseName.isolatedCopy();
 52 identifier.m_openingOrigin = m_openingOrigin.isolatedCopy();
 53 identifier.m_mainFrameOrigin = m_mainFrameOrigin.isolatedCopy();
 54
 55 return WTF::move(identifier);
 56}
4757
4858#ifndef NDEBUG
4959String IDBDatabaseIdentifier::debugString() const

Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h

@@public:
5050 m_mainFrameOrigin.port = -1;
5151 }
5252
 53 IDBDatabaseIdentifier isolatedCopy() const;
 54
5355 bool isHashTableDeletedValue() const
5456 {
5557 return m_openingOrigin.port == -1 && m_mainFrameOrigin.port == -1;

Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp

@@void IDBConnectionToServer::didDeleteDatabase(const IDBResultData& resultData)
7272 request->requestCompleted(resultData);
7373}
7474
 75void IDBConnectionToServer::openDatabase(IDBOpenDBRequest& request)
 76{
 77 LOG(IndexedDB, "IDBConnectionToServer::openDatabase - %s", request.databaseIdentifier().debugString().utf8().data());
 78
 79 ASSERT(!m_openDBRequestMap.contains(request.requestIdentifier()));
 80 m_openDBRequestMap.set(request.requestIdentifier(), &request);
 81
 82 IDBRequestData requestData(*this, request);
 83 m_delegate->openDatabase(requestData);
 84}
 85
 86void IDBConnectionToServer::didOpenDatabase(const IDBResultData& resultData)
 87{
 88 LOG(IndexedDB, "IDBConnectionToServer::didOpenDatabase");
 89
 90 auto request = m_openDBRequestMap.take(resultData.requestIdentifier());
 91 ASSERT(request);
 92
 93 request->requestCompleted(resultData);
 94}
 95
7596} // namespace IDBClient
7697} // namespace WebCore
7798

Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h

@@public:
5050
5151 void deleteDatabase(IDBOpenDBRequest&);
5252 void didDeleteDatabase(const IDBResultData&);
53 
 53
 54 void openDatabase(IDBOpenDBRequest&);
 55 void didOpenDatabase(const IDBResultData&);
 56
5457private:
5558 IDBConnectionToServer(IDBConnectionToServerDelegate&);
5659

Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h

@@public:
4040
4141 virtual uint64_t identifier() const = 0;
4242 virtual void deleteDatabase(IDBRequestData&) = 0;
43 
 43 virtual void openDatabase(IDBRequestData&) = 0;
 44
4445 virtual void ref() = 0;
4546 virtual void deref() = 0;
4647};

Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp

@@RefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* contex
115115 }
116116
117117 auto request = IDBOpenDBRequest::createOpenRequest(m_connectionToServer.get(), context, databaseIdentifier, version);
 118 m_connectionToServer->openDatabase(request.get());
 119
118120 return adoptRef(&request.leakRef());
119121}
120122

Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef IDBBackingStore_h
 27#define IDBBackingStore_h
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "IDBDatabaseInfo.h"
 32
 33namespace WebCore {
 34namespace IDBServer {
 35
 36class IDBBackingStore {
 37public:
 38 virtual ~IDBBackingStore() { }
 39
 40 virtual const IDBDatabaseInfo& getOrEstablishDatabaseInfo() = 0;
 41};
 42
 43} // namespace IDBServer
 44} // namespace WebCore
 45
 46#endif // ENABLE(INDEXED_DATABASE)
 47#endif // IDBBackingStore_h

Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp

@@void IDBConnectionToClient::didDeleteDatabase(const IDBResultData& result)
5151 m_delegate->didDeleteDatabase(result);
5252}
5353
 54void IDBConnectionToClient::didOpenDatabase(const IDBResultData& result)
 55{
 56 m_delegate->didOpenDatabase(result);
 57}
 58
5459} // namespace IDBServer
5560} // namespace WebCore
5661

Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h

@@public:
4545 uint64_t identifier() const;
4646
4747 void didDeleteDatabase(const IDBResultData&);
 48 void didOpenDatabase(const IDBResultData&);
4849
4950private:
5051 IDBConnectionToClient(IDBConnectionToClientDelegate&);

Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h

@@public:
4141 virtual uint64_t identifier() const = 0;
4242
4343 virtual void didDeleteDatabase(const IDBResultData&) = 0;
 44 virtual void didOpenDatabase(const IDBResultData&) = 0;
4445
4546 virtual void ref() = 0;
4647 virtual void deref() = 0;

Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

3131#include "IDBRequestData.h"
3232#include "IDBResultData.h"
3333#include "Logging.h"
 34#include "MemoryIDBBackingStore.h"
 35#include <wtf/Locker.h>
 36#include <wtf/MainThread.h>
3437
3538namespace WebCore {
3639namespace IDBServer {

@@Ref<IDBServer> IDBServer::create()
4245
4346IDBServer::IDBServer()
4447{
 48 Locker<Lock> locker(m_databaseThreadCreationLock);
 49 m_threadID = createThread(IDBServer::databaseThreadEntry, this, "IndexedDatabase Server");
4550}
4651
4752void IDBServer::registerConnection(IDBConnectionToClient& connection)

@@void IDBServer::unregisterConnection(IDBConnectionToClient& connection)
5863 m_connectionMap.remove(connection.identifier());
5964}
6065
61 void IDBServer::deleteDatabase(const IDBRequestData& data)
 66UniqueIDBDatabase& IDBServer::getOrCreateUniqueIDBDatabase(const IDBDatabaseIdentifier& identifier)
6267{
63  LOG(IndexedDB, "IDBServer::deleteDatabase - %s", data.databaseIdentifier().debugString().utf8().data());
 68 auto uniqueIDBDatabase = m_uniqueIDBDatabaseMap.add(identifier, nullptr);
 69 if (uniqueIDBDatabase.isNewEntry)
 70 uniqueIDBDatabase.iterator->value = UniqueIDBDatabase::create(*this, identifier);
 71
 72 return *uniqueIDBDatabase.iterator->value;
 73}
 74
 75std::unique_ptr<IDBBackingStore> IDBServer::createBackingStore(const IDBDatabaseIdentifier& identifier)
 76{
 77 ASSERT(!isMainThread());
 78
 79 // FIXME: For now we only have the in-memory backing store, which we'll continue to use for private browsing.
 80 // Once it's time for persistent backing stores this is where we'll calculate the correct path on disk
 81 // and create it.
 82
 83 return MemoryIDBBackingStore::create(identifier);
 84}
 85
 86void IDBServer::openDatabase(const IDBRequestData& requestData)
 87{
 88 LOG(IndexedDB, "IDBServer::openDatabase");
 89
 90 auto& uniqueIDBDatabase = getOrCreateUniqueIDBDatabase(requestData.databaseIdentifier());
 91
 92 auto connection = m_connectionMap.get(requestData.requestIdentifier().connectionIdentifier());
 93 if (!connection) {
 94 // If the connection back to the client is gone, there's no way to open the database as
 95 // well as no way to message back failure.
 96 return;
 97 }
 98
 99 uniqueIDBDatabase.openDatabaseConnection(*connection, requestData);
 100}
 101
 102void IDBServer::deleteDatabase(const IDBRequestData& requestData)
 103{
 104 LOG(IndexedDB, "IDBServer::deleteDatabase - %s", requestData.databaseIdentifier().debugString().utf8().data());
64105
65  auto connection = m_connectionMap.get(data.requestIdentifier().connectionIdentifier());
 106 auto connection = m_connectionMap.get(requestData.requestIdentifier().connectionIdentifier());
66107 if (!connection) {
67  // If we don't have record of this connection (e.g. it has dropped due to a process crashing)
68  // then we can't report back status of the operation.
69  // Therefore we shouldn't bother performing it.
 108 // If the connection back to the client is gone, there's no way to delete the database as
 109 // well as no way to message back failure.
70110 return;
71111 }
72112
73113 // FIXME: During bringup of modern IDB, the database deletion is a no-op, and is
74114 // immediately reported back to the WebProcess as failure.
75  IDBResultData result(data.requestIdentifier(), IDBError(IDBExceptionCode::Unknown));
 115 IDBResultData result(requestData.requestIdentifier(), IDBError(IDBExceptionCode::Unknown));
76116 connection->didDeleteDatabase(result);
77117}
78118
 119void IDBServer::postDatabaseTask(std::unique_ptr<CrossThreadTask>&& task)
 120{
 121 ASSERT(isMainThread());
 122 m_databaseQueue.append(WTF::move(task));
 123}
 124
 125void IDBServer::postDatabaseTaskReply(std::unique_ptr<CrossThreadTask>&& task)
 126{
 127 ASSERT(!isMainThread());
 128 m_databaseReplyQueue.append(WTF::move(task));
 129
 130
 131 Locker<Lock> locker(m_mainThreadReplyLock);
 132 if (m_mainThreadReplyScheduled)
 133 return;
 134
 135 m_mainThreadReplyScheduled = true;
 136 callOnMainThread([this] {
 137 handleTaskRepliesOnMainThread();
 138 });
 139}
 140
 141void IDBServer::databaseThreadEntry(void* threadData)
 142{
 143 ASSERT(threadData);
 144 IDBServer* server = reinterpret_cast<IDBServer*>(threadData);
 145 server->databaseRunLoop();
 146}
 147
 148void IDBServer::databaseRunLoop()
 149{
 150 ASSERT(!isMainThread());
 151 {
 152 Locker<Lock> locker(m_databaseThreadCreationLock);
 153 }
 154
 155 while (auto task = m_databaseQueue.waitForMessage())
 156 task->performTask();
 157}
 158
 159void IDBServer::handleTaskRepliesOnMainThread()
 160{
 161 {
 162 Locker<Lock> locker(m_mainThreadReplyLock);
 163 m_mainThreadReplyScheduled = false;
 164 }
 165
 166 while (auto task = m_databaseReplyQueue.tryGetMessage())
 167 task->performTask();
 168}
 169
79170} // namespace IDBServer
80171} // namespace WebCore
81172

Source/WebCore/Modules/indexeddb/server/IDBServer.h

2828
2929#if ENABLE(INDEXED_DATABASE)
3030
 31#include "CrossThreadTask.h"
3132#include "IDBConnectionToClient.h"
 33#include "IDBDatabaseIdentifier.h"
 34#include "UniqueIDBDatabase.h"
3235#include <wtf/HashMap.h>
 36#include <wtf/Lock.h>
 37#include <wtf/MessageQueue.h>
3338#include <wtf/Ref.h>
3439#include <wtf/RefCounted.h>
3540#include <wtf/RefPtr.h>
3641
3742namespace WebCore {
3843
 44class CrossThreadTask;
3945class IDBRequestData;
4046
4147namespace IDBServer {

@@public:
4854 void unregisterConnection(IDBConnectionToClient&);
4955
5056 // Operations requested by the client.
 57 void openDatabase(const IDBRequestData&);
5158 void deleteDatabase(const IDBRequestData&);
5259
 60 void postDatabaseTask(std::unique_ptr<CrossThreadTask>&&);
 61 void postDatabaseTaskReply(std::unique_ptr<CrossThreadTask>&&);
 62
 63 std::unique_ptr<IDBBackingStore> createBackingStore(const IDBDatabaseIdentifier&);
 64
5365private:
5466 IDBServer();
5567
 68 UniqueIDBDatabase& getOrCreateUniqueIDBDatabase(const IDBDatabaseIdentifier&);
 69
 70 static void databaseThreadEntry(void*);
 71 void databaseRunLoop();
 72 void handleTaskRepliesOnMainThread();
 73
5674 HashMap<uint64_t, RefPtr<IDBConnectionToClient>> m_connectionMap;
 75 HashMap<IDBDatabaseIdentifier, RefPtr<UniqueIDBDatabase>> m_uniqueIDBDatabaseMap;
 76
 77 ThreadIdentifier m_threadID { 0 };
 78 Lock m_databaseThreadCreationLock;
 79 Lock m_mainThreadReplyLock;
 80 bool m_mainThreadReplyScheduled { false };
 81
 82 MessageQueue<CrossThreadTask> m_databaseQueue;
 83 MessageQueue<CrossThreadTask> m_databaseReplyQueue;
5784};
5885
5986} // namespace IDBServer

Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "IDBServerOperation.h"
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include <wtf/RefCounted.h>
 32
 33namespace WebCore {
 34namespace IDBServer {
 35
 36Ref<IDBServerOperation> IDBServerOperation::create(IDBConnectionToClient& connection, const IDBRequestData& requestData)
 37{
 38 return adoptRef(*new IDBServerOperation(connection, requestData));
 39}
 40
 41IDBServerOperation::IDBServerOperation(IDBConnectionToClient& connection, const IDBRequestData& requestData)
 42 : m_connection(connection)
 43 , m_requestData(requestData)
 44{
 45}
 46
 47} // namespace IDBServer
 48} // namespace WebCore
 49
 50#endif // ENABLE(INDEXED_DATABASE)

Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef IDBServerOperation_h
 27#define IDBServerOperation_h
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "IDBConnectionToClient.h"
 32#include "IDBRequestData.h"
 33#include <wtf/Ref.h>
 34#include <wtf/RefCounted.h>
 35
 36namespace WebCore {
 37namespace IDBServer {
 38
 39class IDBServerOperation : public RefCounted<IDBServerOperation> {
 40public:
 41 static Ref<IDBServerOperation> create(IDBConnectionToClient&, const IDBRequestData&);
 42
 43 IDBConnectionToClient& connection() { return m_connection; }
 44 const IDBRequestData& requestData() const { return m_requestData; }
 45
 46private:
 47 IDBServerOperation(IDBConnectionToClient&, const IDBRequestData&);
 48
 49 IDBConnectionToClient& m_connection;
 50 IDBRequestData m_requestData;
 51};
 52
 53} // namespace IDBServer
 54} // namespace WebCore
 55
 56#endif // ENABLE(INDEXED_DATABASE)
 57#endif // IDBServerOperation_h

Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "MemoryIDBBackingStore.h"
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31namespace WebCore {
 32namespace IDBServer {
 33
 34std::unique_ptr<MemoryIDBBackingStore> MemoryIDBBackingStore::create(const IDBDatabaseIdentifier& identifier)
 35{
 36 return std::make_unique<MemoryIDBBackingStore>(identifier);
 37}
 38
 39MemoryIDBBackingStore::MemoryIDBBackingStore(const IDBDatabaseIdentifier& identifier)
 40 : m_identifier(identifier)
 41{
 42}
 43
 44MemoryIDBBackingStore::~MemoryIDBBackingStore()
 45{
 46}
 47
 48const IDBDatabaseInfo& MemoryIDBBackingStore::getOrEstablishDatabaseInfo()
 49{
 50 if (!m_databaseInfo)
 51 m_databaseInfo = std::make_unique<IDBDatabaseInfo>(m_identifier.databaseName(), 0);
 52
 53 return *m_databaseInfo;
 54}
 55
 56} // namespace IDBServer
 57} // namespace WebCore
 58
 59#endif // ENABLE(INDEXED_DATABASE)

Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef MemoryIDBBackingStore_h
 27#define MemoryIDBBackingStore_h
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "IDBBackingStore.h"
 32#include "IDBDatabaseIdentifier.h"
 33
 34namespace WebCore {
 35namespace IDBServer {
 36
 37class MemoryIDBBackingStore : public IDBBackingStore {
 38 friend std::unique_ptr<MemoryIDBBackingStore> std::make_unique<MemoryIDBBackingStore>(const IDBDatabaseIdentifier&);
 39public:
 40 static std::unique_ptr<MemoryIDBBackingStore> create(const IDBDatabaseIdentifier&);
 41
 42 virtual ~MemoryIDBBackingStore() override final;
 43
 44 virtual const IDBDatabaseInfo& getOrEstablishDatabaseInfo() override final;
 45
 46private:
 47 MemoryIDBBackingStore(const IDBDatabaseIdentifier&);
 48
 49 IDBDatabaseIdentifier m_identifier;
 50 std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
 51};
 52
 53} // namespace IDBServer
 54} // namespace WebCore
 55
 56#endif // ENABLE(INDEXED_DATABASE)
 57#endif // MemoryIDBBackingStore_h

Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "UniqueIDBDatabase.h"
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "IDBResultData.h"
 32#include "IDBServer.h"
 33#include "Logging.h"
 34#include <wtf/MainThread.h>
 35#include <wtf/ThreadSafeRefCounted.h>
 36
 37namespace WebCore {
 38namespace IDBServer {
 39
 40UniqueIDBDatabase::UniqueIDBDatabase(IDBServer& server, const IDBDatabaseIdentifier& identifier)
 41 : m_server(server)
 42 , m_identifier(identifier)
 43{
 44}
 45
 46void UniqueIDBDatabase::openDatabaseConnection(IDBConnectionToClient& connection, const IDBRequestData& requestData)
 47{
 48 auto operation = IDBServerOperation::create(connection, requestData);
 49 m_pendingOpenDatabaseOperations.append(WTF::move(operation));
 50
 51 if (m_databaseInfo) {
 52 handleOpenDatabaseOperations();
 53 return;
 54 }
 55
 56 m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::openBackingStore, m_identifier));
 57}
 58
 59void UniqueIDBDatabase::handleOpenDatabaseOperations()
 60{
 61 ASSERT(isMainThread());
 62 LOG(IndexedDB, "(main) UniqueIDBDatabase::handleOpenDatabaseOperations");
 63
 64 auto operation = m_pendingOpenDatabaseOperations.takeFirst();
 65
 66 // FIXME: Reporting open operations as failures for now.
 67 // Creating database connections for success will be the next step.
 68
 69 IDBResultData result(operation->requestData().requestIdentifier(), IDBError(IDBExceptionCode::Unknown));
 70 operation->connection().didOpenDatabase(result);
 71}
 72
 73void UniqueIDBDatabase::openBackingStore(const IDBDatabaseIdentifier& identifier)
 74{
 75 ASSERT(!isMainThread());
 76 LOG(IndexedDB, "(db) UniqueIDBDatabase::openBackingStore");
 77
 78 ASSERT(!m_backingStore);
 79 m_backingStore = m_server.createBackingStore(identifier);
 80 auto databaseInfo = m_backingStore->getOrEstablishDatabaseInfo();
 81
 82 m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didOpenBackingStore, databaseInfo));
 83}
 84
 85void UniqueIDBDatabase::didOpenBackingStore(const IDBDatabaseInfo& info)
 86{
 87 ASSERT(isMainThread());
 88 LOG(IndexedDB, "(main) UniqueIDBDatabase::didOpenBackingStore");
 89
 90 m_databaseInfo = std::make_unique<IDBDatabaseInfo>(info);
 91
 92 handleOpenDatabaseOperations();
 93}
 94
 95} // namespace IDBServer
 96} // namespace WebCore
 97
 98#endif // ENABLE(INDEXED_DATABASE)

Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef UniqueIDBDatabase_h
 27#define UniqueIDBDatabase_h
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "IDBBackingStore.h"
 32#include "IDBDatabaseIdentifier.h"
 33#include "IDBDatabaseInfo.h"
 34#include "IDBServerOperation.h"
 35#include <wtf/Deque.h>
 36#include <wtf/Ref.h>
 37#include <wtf/ThreadSafeRefCounted.h>
 38
 39namespace WebCore {
 40
 41class IDBRequestData;
 42
 43namespace IDBServer {
 44
 45class IDBConnectionToClient;
 46class IDBServer;
 47
 48class UniqueIDBDatabase : public ThreadSafeRefCounted<UniqueIDBDatabase> {
 49public:
 50 static Ref<UniqueIDBDatabase> create(IDBServer& server, const IDBDatabaseIdentifier& identifier)
 51 {
 52 return adoptRef(*new UniqueIDBDatabase(server, identifier));
 53 }
 54
 55 void openDatabaseConnection(IDBConnectionToClient&, const IDBRequestData&);
 56
 57private:
 58 UniqueIDBDatabase(IDBServer&, const IDBDatabaseIdentifier&);
 59
 60 void handleOpenDatabaseOperations();
 61
 62 // Database thread operations
 63 void openBackingStore(const IDBDatabaseIdentifier&);
 64
 65 // Main thread callbacks
 66 void didOpenBackingStore(const IDBDatabaseInfo&);
 67
 68 IDBServer& m_server;
 69 IDBDatabaseIdentifier m_identifier;
 70
 71 Deque<Ref<IDBServerOperation>> m_pendingOpenDatabaseOperations;
 72
 73 std::unique_ptr<IDBBackingStore> m_backingStore;
 74 std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
 75};
 76
 77} // namespace IDBServer
 78} // namespace WebCore
 79
 80#endif // ENABLE(INDEXED_DATABASE)
 81#endif // UniqueIDBDatabase_h

Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.cpp

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "IDBDatabaseInfo.h"
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31namespace WebCore {
 32
 33IDBDatabaseInfo::IDBDatabaseInfo(const String& name, uint64_t version)
 34 : m_name(name)
 35 , m_version(version)
 36{
 37}
 38
 39IDBDatabaseInfo IDBDatabaseInfo::isolatedCopy() const
 40{
 41 IDBDatabaseInfo info;
 42
 43 info.m_name = m_name.isolatedCopy();
 44 info.m_version = m_version;
 45
 46 return WTF::move(info);
 47}
 48
 49} // namespace WebCore
 50
 51#endif // ENABLE(INDEXED_DATABASE)

Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.h

 1/*
 2 * Copyright (C) 2015 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef IDBDatabaseInfo_h
 27#define IDBDatabaseInfo_h
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include <wtf/text/WTFString.h>
 32
 33namespace WebCore {
 34
 35class IDBDatabaseInfo {
 36public:
 37 IDBDatabaseInfo(const String& name, uint64_t version);
 38
 39 IDBDatabaseInfo isolatedCopy() const;
 40
 41private:
 42 IDBDatabaseInfo()
 43 {
 44 }
 45
 46 String m_name;
 47 uint64_t m_version { 0 };
 48};
 49
 50} // namespace WebCore
 51
 52#endif // ENABLE(INDEXED_DATABASE)
 53#endif // IDBDatabaseInfo_h

Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp

@@void InProcessIDBServer::didDeleteDatabase(const IDBResultData& resultData)
8383 RefPtr<InProcessIDBServer> self(this);
8484 RunLoop::current().dispatch([this, self, resultData] {
8585 m_connectionToServer->didDeleteDatabase(resultData);
86  });}
 86 });
 87}
 88
 89void InProcessIDBServer::openDatabase(IDBRequestData& requestData)
 90{
 91 RefPtr<InProcessIDBServer> self(this);
 92 RunLoop::current().dispatch([this, self, requestData] {
 93 m_server->openDatabase(requestData);
 94 });
 95}
 96
 97void InProcessIDBServer::didOpenDatabase(const IDBResultData& resultData)
 98{
 99 RefPtr<InProcessIDBServer> self(this);
 100 RunLoop::current().dispatch([this, self, resultData] {
 101 m_connectionToServer->didOpenDatabase(resultData);
 102 });
 103}
87104
88105} // namespace WebCore
89106

Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h

@@public:
5555
5656 // IDBConnectionToServer
5757 virtual void deleteDatabase(IDBRequestData&) override final;
58 
 58 virtual void openDatabase(IDBRequestData&) override final;
 59
5960 // IDBConnectionToClient
6061 virtual uint64_t identifier() const override;
6162 virtual void didDeleteDatabase(const IDBResultData&) override final;
 63 virtual void didOpenDatabase(const IDBResultData&) override final;
6264
6365 virtual void ref() override { RefCounted<InProcessIDBServer>::ref(); }
6466 virtual void deref() override { RefCounted<InProcessIDBServer>::deref(); }

Source/WebCore/WebCore.xcodeproj/project.pbxproj

20992099 5185FCB91BB4CBF80012898F /* IDBConnectionToClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 510A58FE1BB07AA500C19282 /* IDBConnectionToClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
21002100 5185FCBA1BB4CBF80012898F /* IDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510A58EF1BAB720F00C19282 /* IDBServer.cpp */; };
21012101 5185FCBB1BB4CBF80012898F /* IDBServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 510A58F01BAB720F00C19282 /* IDBServer.h */; settings = {ATTRIBUTES = (Private, ); }; };
 2102 518864E01BBAF57100E540C9 /* UniqueIDBDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 518864DE1BBAF30F00E540C9 /* UniqueIDBDatabase.cpp */; };
 2103 518864E11BBAF57400E540C9 /* UniqueIDBDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 518864DF1BBAF30F00E540C9 /* UniqueIDBDatabase.h */; };
 2104 518864E61BBB4B8300E540C9 /* IDBServerOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 518864E41BBB4B7E00E540C9 /* IDBServerOperation.cpp */; };
 2105 518864E71BBB4B8300E540C9 /* IDBServerOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 518864E51BBB4B7E00E540C9 /* IDBServerOperation.h */; };
21022106 5189F01D10B37BD900F3C739 /* JSPopStateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5189F01B10B37BD900F3C739 /* JSPopStateEvent.cpp */; };
21032107 5189F01E10B37BD900F3C739 /* JSPopStateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 5189F01C10B37BD900F3C739 /* JSPopStateEvent.h */; };
21042108 5189F0DE10B46B0E00F3C739 /* PopStateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5189F0DD10B46B0E00F3C739 /* PopStateEvent.cpp */; };

21272131 51B45D201AB8D1E200117CD2 /* ContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */; };
21282132 51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
21292133 51B58FD4195A964D002990B0 /* PlatformGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E5FEF195101470086CA5E /* PlatformGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; };
 2134 51BA4AC31BBB5CD800DF3D6D /* IDBDatabaseInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA4AC11BBB5CBF00DF3D6D /* IDBDatabaseInfo.cpp */; };
 2135 51BA4AC41BBB5CD800DF3D6D /* IDBDatabaseInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA4AC21BBB5CBF00DF3D6D /* IDBDatabaseInfo.h */; };
 2136 51BA4ACA1BBC5BD900DF3D6D /* MemoryIDBBackingStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA4AC81BBC5B9E00DF3D6D /* MemoryIDBBackingStore.cpp */; };
 2137 51BA4ACB1BBC5BD900DF3D6D /* MemoryIDBBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA4AC91BBC5B9E00DF3D6D /* MemoryIDBBackingStore.h */; };
 2138 51BA4ACC1BBC5BDD00DF3D6D /* IDBBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA4AC71BBC5AD600DF3D6D /* IDBBackingStore.h */; };
21302139 51BE37E00DAEE00E001085FC /* StorageArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE37DE0DAEE00E001085FC /* StorageArea.h */; settings = {ATTRIBUTES = (Private, ); }; };
21312140 51C0AA390F2AA10A001648C2 /* CachedFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C0AA380F2AA10A001648C2 /* CachedFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
21322141 51C0AA410F2AA15E001648C2 /* CachedFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */; };

94149423 5185FCB61BB4C7610012898F /* DOMRequestState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMRequestState.h; sourceTree = "<group>"; };
94159424 5185FCBC1BB5CB770012898F /* IDBConnectionToServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBConnectionToServer.cpp; sourceTree = "<group>"; };
94169425 5185FCBD1BB5CB770012898F /* IDBConnectionToServerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBConnectionToServerDelegate.h; sourceTree = "<group>"; };
 9426 518864DE1BBAF30F00E540C9 /* UniqueIDBDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueIDBDatabase.cpp; sourceTree = "<group>"; };
 9427 518864DF1BBAF30F00E540C9 /* UniqueIDBDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueIDBDatabase.h; sourceTree = "<group>"; };
 9428 518864E41BBB4B7E00E540C9 /* IDBServerOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBServerOperation.cpp; sourceTree = "<group>"; };
 9429 518864E51BBB4B7E00E540C9 /* IDBServerOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBServerOperation.h; sourceTree = "<group>"; };
94179430 5189F01B10B37BD900F3C739 /* JSPopStateEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPopStateEvent.cpp; sourceTree = "<group>"; };
94189431 5189F01C10B37BD900F3C739 /* JSPopStateEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPopStateEvent.h; sourceTree = "<group>"; };
94199432 5189F0DD10B46B0E00F3C739 /* PopStateEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PopStateEvent.cpp; sourceTree = "<group>"; };

94519464 51B454E91B4DAE7D0085EAA6 /* PingHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PingHandle.h; sourceTree = "<group>"; };
94529465 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtension.cpp; sourceTree = "<group>"; };
94539466 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtension.h; sourceTree = "<group>"; };
 9467 51BA4AC11BBB5CBF00DF3D6D /* IDBDatabaseInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBDatabaseInfo.cpp; sourceTree = "<group>"; };
 9468 51BA4AC21BBB5CBF00DF3D6D /* IDBDatabaseInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBDatabaseInfo.h; sourceTree = "<group>"; };
 9469 51BA4AC71BBC5AD600DF3D6D /* IDBBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBBackingStore.h; sourceTree = "<group>"; };
 9470 51BA4AC81BBC5B9E00DF3D6D /* MemoryIDBBackingStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryIDBBackingStore.cpp; sourceTree = "<group>"; };
 9471 51BA4AC91BBC5B9E00DF3D6D /* MemoryIDBBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryIDBBackingStore.h; sourceTree = "<group>"; };
94549472 51BE37DE0DAEE00E001085FC /* StorageArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageArea.h; sourceTree = "<group>"; };
94559473 51C0AA380F2AA10A001648C2 /* CachedFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFrame.h; sourceTree = "<group>"; };
94569474 51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CachedFrame.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };

1663616654 510A58E11BAA409800C19282 /* shared */ = {
1663716655 isa = PBXGroup;
1663816656 children = (
 16657 51BA4AC11BBB5CBF00DF3D6D /* IDBDatabaseInfo.cpp */,
 16658 51BA4AC21BBB5CBF00DF3D6D /* IDBDatabaseInfo.h */,
1663916659 5148453C1BB9D076006A72ED /* IDBError.cpp */,
1664016660 5148453D1BB9D076006A72ED /* IDBError.h */,
1664116661 510A58F51BACC4A500C19282 /* IDBRequestData.cpp */,

1665316673 510A58EE1BAB71E000C19282 /* server */ = {
1665416674 isa = PBXGroup;
1665516675 children = (
 16676 51BA4AC71BBC5AD600DF3D6D /* IDBBackingStore.h */,
1665616677 516D7D6D1BB5F06500AF7C77 /* IDBConnectionToClient.cpp */,
1665716678 510A58FE1BB07AA500C19282 /* IDBConnectionToClient.h */,
1665816679 516D7D6E1BB5F06500AF7C77 /* IDBConnectionToClientDelegate.h */,
1665916680 510A58EF1BAB720F00C19282 /* IDBServer.cpp */,
1666016681 510A58F01BAB720F00C19282 /* IDBServer.h */,
 16682 518864E41BBB4B7E00E540C9 /* IDBServerOperation.cpp */,
 16683 518864E51BBB4B7E00E540C9 /* IDBServerOperation.h */,
 16684 51BA4AC81BBC5B9E00DF3D6D /* MemoryIDBBackingStore.cpp */,
 16685 51BA4AC91BBC5B9E00DF3D6D /* MemoryIDBBackingStore.h */,
 16686 518864DE1BBAF30F00E540C9 /* UniqueIDBDatabase.cpp */,
 16687 518864DF1BBAF30F00E540C9 /* UniqueIDBDatabase.h */,
1666116688 );
1666216689 path = server;
1666316690 sourceTree = "<group>";

2465624683 BC64641C11D7F416006455B0 /* DatasetDOMStringMap.h in Headers */,
2465724684 85031B3E0A44EFC700F992E0 /* DataTransfer.h in Headers */,
2465824685 4B8AF4AA0B1CE02B00687690 /* DataTransferAccessPolicy.h in Headers */,
 24686 51BA4ACC1BBC5BDD00DF3D6D /* IDBBackingStore.h in Headers */,
2465924687 81AC5999131636E60009A7E0 /* DataTransferItem.h in Headers */,
2466024688 81AC599A131636E60009A7E0 /* DataTransferItemList.h in Headers */,
2466124689 E4A007831B820EC8002C5A6E /* DataURLDecoder.h in Headers */,

2594525973 A84EBD830CB8C97700079609 /* JSStyleSheetList.h in Headers */,
2594625974 E1FF8F65180745D800132674 /* JSSubtleCrypto.h in Headers */,
2594725975 B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */,
 25976 518864E71BBB4B8300E540C9 /* IDBServerOperation.h in Headers */,
2594825977 24D9129213CA951E00D21915 /* JSSVGAltGlyphDefElement.h in Headers */,
2594925978 6515EC920D9723FF0063D49A /* JSSVGAltGlyphElement.h in Headers */,
2595025979 24D9129613CA956100D21915 /* JSSVGAltGlyphItemElement.h in Headers */,

2655126580 BC5C762B1497FE1400BC4775 /* PlatformEvent.h in Headers */,
2655226581 26601EBF14B3B9AD0012C0FE /* PlatformEventFactoryIOS.h in Headers */,
2655326582 BCAA487014A052530088FAC4 /* PlatformEventFactoryMac.h in Headers */,
 26583 51BA4AC41BBB5CD800DF3D6D /* IDBDatabaseInfo.h in Headers */,
2655426584 A723F77B1484CA4C008C6DBE /* PlatformExportMacros.h in Headers */,
2655526585 51B58FD4195A964D002990B0 /* PlatformGamepad.h in Headers */,
2655626586 935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */,

2660226632 B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */,
2660326633 A8EA7EBC0A1945D000A8EF5F /* ProcessingInstruction.h in Headers */,
2660426634 E44613EC0CD681B500FADA75 /* ProgressEvent.h in Headers */,
 26635 518864E11BBAF57400E540C9 /* UniqueIDBDatabase.h in Headers */,
2660526636 A715E653134BBBEC00D8E713 /* ProgressShadowElement.h in Headers */,
2660626637 1A2A68240B5BEDE70002A480 /* ProgressTracker.h in Headers */,
2660726638 1ACADD791880D91C00D8B71D /* ProgressTrackerClient.h in Headers */,

2682826859 514C767F0CE923A1007EF3CD /* ResourceResponseBase.h in Headers */,
2682926860 FD3160A512B026F700C1A359 /* Reverb.h in Headers */,
2683026861 FD3160A712B026F700C1A359 /* ReverbAccumulationBuffer.h in Headers */,
 26862 51BA4ACB1BBC5BD900DF3D6D /* MemoryIDBBackingStore.h in Headers */,
2683126863 FD3160A912B026F700C1A359 /* ReverbConvolver.h in Headers */,
2683226864 FD3160AB12B026F700C1A359 /* ReverbConvolverStage.h in Headers */,
2683326865 FD3160AD12B026F700C1A359 /* ReverbInputBuffer.h in Headers */,

2815828190 45830D4D1679B4F800ACF8C3 /* AutoscrollController.cpp in Sources */,
2815928191 A8CFF0500A154F09000A4234 /* AutoTableLayout.cpp in Sources */,
2816028192 070363E1181A1CDC00C074A5 /* AVAudioCaptureSource.mm in Sources */,
 28193 518864E61BBB4B8300E540C9 /* IDBServerOperation.cpp in Sources */,
2816128194 070363E3181A1CDC00C074A5 /* AVCaptureDeviceManager.mm in Sources */,
2816228195 070363E5181A1CDC00C074A5 /* AVMediaCaptureSource.mm in Sources */,
2816328196 CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */,

2861528648 8540756C0AD6CBF900620C57 /* DOMHTMLOptionElement.mm in Sources */,
2861628649 85DF2F9C0AA3CAE500AD64C5 /* DOMHTMLOptionsCollection.mm in Sources */,
2861728650 85183B470AA6926100F19FA3 /* DOMHTMLParagraphElement.mm in Sources */,
 28651 518864E01BBAF57100E540C9 /* UniqueIDBDatabase.cpp in Sources */,
2861828652 85ECBEF80AA7626900544F0B /* DOMHTMLParamElement.mm in Sources */,
2861928653 85183B490AA6926100F19FA3 /* DOMHTMLPreElement.mm in Sources */,
2862028654 A4226E961163D73A008B8397 /* DOMHTMLProgressElement.mm in Sources */,

3004730081 443F04270E75C8FB007E5407 /* NetworkStateNotifierIOS.mm in Sources */,
3004830082 1A7FA6490DDA3CBA0028F8A5 /* NetworkStateNotifierMac.cpp in Sources */,
3004930083 E13EF34916850C470034C83F /* NetworkStorageSessionCFNet.cpp in Sources */,
 30084 51BA4ACA1BBC5BD900DF3D6D /* MemoryIDBBackingStore.cpp in Sources */,
3005030085 269397261A4A5FBD00E8349D /* NFA.cpp in Sources */,
3005130086 267726001A5B3AD9003C24DD /* NFAToDFA.cpp in Sources */,
3005230087 BCEF43E00E674110001C1287 /* NinePieceImage.cpp in Sources */,

3085430889 A1DE71321861322200734192 /* TouchConstructors.cpp in Sources */,
3085530890 A1DE712D18612AC100734192 /* TouchEvents.cpp in Sources */,
3085630891 070334D9145A006F008D8D45 /* TrackBase.cpp in Sources */,
 30892 51BA4AC31BBB5CD800DF3D6D /* IDBDatabaseInfo.cpp in Sources */,
3085730893 070334D31459FFAD008D8D45 /* TrackEvent.cpp in Sources */,
3085830894 BE88E0C11715CE2600658D98 /* TrackListBase.cpp in Sources */,
3085930895 FFAC30FF184FB145008C4F1E /* TrailingObjects.cpp in Sources */,

Source/WebCore/platform/CrossThreadCopier.cpp

4242#include <wtf/text/WTFString.h>
4343
4444#if ENABLE(INDEXED_DATABASE)
 45#include "IDBDatabaseIdentifier.h"
 46#include "IDBDatabaseInfo.h"
4547#include "IDBDatabaseMetadata.h"
4648#include "IDBGetResult.h"
4749#include "IDBKeyData.h"

@@CrossThreadCopierBase<false, false, IDBObjectStoreMetadata>::Type CrossThreadCop
127129 return metadata.isolatedCopy();
128130}
129131
 132CrossThreadCopierBase<false, false, IDBDatabaseInfo>::Type CrossThreadCopierBase<false, false, IDBDatabaseInfo>::copy(const IDBDatabaseInfo& info)
 133{
 134 return info.isolatedCopy();
 135}
 136
 137CrossThreadCopierBase<false, false, IDBDatabaseIdentifier>::Type CrossThreadCopierBase<false, false, IDBDatabaseIdentifier>::copy(const IDBDatabaseIdentifier& identifier)
 138{
 139 return identifier.isolatedCopy();
 140}
130141#endif
131142
132143// Test CrossThreadCopier using COMPILE_ASSERT.

Source/WebCore/platform/CrossThreadCopier.h

@@namespace WebCore {
190190 typedef IDBObjectStoreMetadata Type;
191191 static Type copy(const IDBObjectStoreMetadata&);
192192 };
 193
 194 class IDBDatabaseInfo;
 195 template<> struct WEBCORE_EXPORT CrossThreadCopierBase<false, false, IDBDatabaseInfo> {
 196 typedef IDBDatabaseInfo Type;
 197 static Type copy(const IDBDatabaseInfo&);
 198 };
 199
 200 class IDBDatabaseIdentifier;
 201 template<> struct WEBCORE_EXPORT CrossThreadCopierBase<false, false, IDBDatabaseIdentifier> {
 202 typedef IDBDatabaseIdentifier Type;
 203 static Type copy(const IDBDatabaseIdentifier&);
 204 };
 205
193206#endif
194207
195208 template<typename T>