WebToDatabaseProcessConnection.cpp [plain text]
#include "config.h"
#include "WebToDatabaseProcessConnection.h"
#include "DatabaseToWebProcessConnectionMessages.h"
#include "WebIDBConnectionToServerMessages.h"
#include "WebProcess.h"
#include <wtf/RunLoop.h>
#if ENABLE(DATABASE_PROCESS)
using namespace WebCore;
namespace WebKit {
WebToDatabaseProcessConnection::WebToDatabaseProcessConnection(IPC::Connection::Identifier connectionIdentifier)
: m_connection(IPC::Connection::createClientConnection(connectionIdentifier, *this))
{
m_connection->open();
}
WebToDatabaseProcessConnection::~WebToDatabaseProcessConnection()
{
}
void WebToDatabaseProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
{
#if ENABLE(INDEXED_DATABASE)
if (decoder.messageReceiverName() == Messages::WebIDBConnectionToServer::messageReceiverName()) {
auto idbConnection = m_webIDBConnectionsByIdentifier.get(decoder.destinationID());
if (idbConnection)
idbConnection->didReceiveMessage(connection, decoder);
return;
}
#endif
ASSERT_NOT_REACHED();
}
void WebToDatabaseProcessConnection::didClose(IPC::Connection& connection)
{
#if ENABLE(INDEXED_DATABASE)
for (auto& connection : m_webIDBConnectionsByIdentifier.values())
connection->connectionToServerLost();
m_webIDBConnectionsByIdentifier.clear();
m_webIDBConnectionsBySession.clear();
#endif
WebProcess::singleton().webToDatabaseProcessConnectionClosed(this);
}
void WebToDatabaseProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName)
{
}
#if ENABLE(INDEXED_DATABASE)
WebIDBConnectionToServer& WebToDatabaseProcessConnection::idbConnectionToServerForSession(const SessionID& sessionID)
{
auto result = m_webIDBConnectionsBySession.add(sessionID, nullptr);
if (result.isNewEntry) {
result.iterator->value = WebIDBConnectionToServer::create();
ASSERT(!m_webIDBConnectionsByIdentifier.contains(result.iterator->value->identifier()));
m_webIDBConnectionsByIdentifier.set(result.iterator->value->identifier(), result.iterator->value);
}
return *result.iterator->value;
}
#endif
}
#endif // ENABLE(DATABASE_PROCESS)