This source file includes following definitions.
- from
- supplementName
- didOpenDatabase
- createInspectorAgentFor
- provideDatabaseClientTo
- provideDatabaseClientToWorker
#include "config.h"
#include "DatabaseClient.h"
#include "core/dom/Document.h"
#include "core/inspector/InspectorController.h"
#include "core/workers/WorkerGlobalScope.h"
#include "modules/webdatabase/Database.h"
#include "modules/webdatabase/InspectorDatabaseAgent.h"
namespace WebCore {
DatabaseClient::DatabaseClient()
: m_inspectorAgent(0)
{ }
DatabaseClient* DatabaseClient::from(ExecutionContext* context)
{
if (context->isDocument()) {
return static_cast<DatabaseClient*>(Supplement<Page>::from(toDocument(context)->page(), supplementName()));
}
ASSERT(context->isWorkerGlobalScope());
return static_cast<DatabaseClient*>(Supplement<WorkerClients>::from(toWorkerGlobalScope(context)->clients(), supplementName()));
}
const char* DatabaseClient::supplementName()
{
return "DatabaseClient";
}
void DatabaseClient::didOpenDatabase(PassRefPtrWillBeRawPtr<Database> database, const String& domain, const String& name, const String& version)
{
if (m_inspectorAgent)
m_inspectorAgent->didOpenDatabase(database, domain, name, version);
}
void DatabaseClient::createInspectorAgentFor(Page* page)
{
ASSERT(!m_inspectorAgent);
OwnPtr<InspectorDatabaseAgent> inspectorAgent = InspectorDatabaseAgent::create();
m_inspectorAgent = inspectorAgent.get();
page->inspectorController().registerModuleAgent(inspectorAgent.release());
}
void provideDatabaseClientTo(Page& page, PassOwnPtr<DatabaseClient> client)
{
DatabaseClient* clientPtr = client.get();
page.provideSupplement(DatabaseClient::supplementName(), client);
clientPtr->createInspectorAgentFor(&page);
}
void provideDatabaseClientToWorker(WorkerClients* workerClients, PassOwnPtr<DatabaseClient> client)
{
workerClients->provideSupplement(DatabaseClient::supplementName(), client);
}
}