diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/modules/webdatabase/DatabaseClient.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/modules/webdatabase/DatabaseClient.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/chromium/third_party/WebKit/Source/modules/webdatabase/DatabaseClient.cpp b/chromium/third_party/WebKit/Source/modules/webdatabase/DatabaseClient.cpp index ef4c9e88d18..be3434855f6 100644 --- a/chromium/third_party/WebKit/Source/modules/webdatabase/DatabaseClient.cpp +++ b/chromium/third_party/WebKit/Source/modules/webdatabase/DatabaseClient.cpp @@ -32,17 +32,24 @@ #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())); + return static_cast<DatabaseClient*>(WillBeHeapSupplement<Page>::from(toDocument(context)->page(), supplementName())); } ASSERT(context->isWorkerGlobalScope()); - return static_cast<DatabaseClient*>(Supplement<WorkerClients>::from(toWorkerGlobalScope(context)->clients(), supplementName())); + return static_cast<DatabaseClient*>(WillBeHeapSupplement<WorkerClients>::from(toWorkerGlobalScope(context)->clients(), supplementName())); } const char* DatabaseClient::supplementName() @@ -50,12 +57,28 @@ const char* DatabaseClient::supplementName() return "DatabaseClient"; } -void provideDatabaseClientTo(Page* page, PassOwnPtr<DatabaseClient> client) +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, PassOwnPtrWillBeRawPtr<DatabaseClient> client) { - page->provideSupplement(DatabaseClient::supplementName(), client); + DatabaseClient* clientPtr = client.get(); + page.provideSupplement(DatabaseClient::supplementName(), client); + clientPtr->createInspectorAgentFor(&page); } -void provideDatabaseClientToWorker(WorkerClients* workerClients, PassOwnPtr<DatabaseClient> client) +void provideDatabaseClientToWorker(WorkerClients* workerClients, PassOwnPtrWillBeRawPtr<DatabaseClient> client) { workerClients->provideSupplement(DatabaseClient::supplementName(), client); } |