Diff
Modified: trunk/LayoutTests/ChangeLog (243218 => 243219)
--- trunk/LayoutTests/ChangeLog 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/LayoutTests/ChangeLog 2019-03-20 18:53:47 UTC (rev 243219)
@@ -1,3 +1,14 @@
+2019-03-20 Devin Rousso <[email protected]>
+
+ Web Inspector: Database: lazily create the agent
+ https://bugs.webkit.org/show_bug.cgi?id=195587
+ <rdar://problem/48791735>
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/protocol/backend-dispatcher-argument-errors.html:
+ * inspector/runtime/CommandLineAPI-inspect.html:
+
2019-03-20 Simon Fraser <[email protected]>
Some elements lag behind async overflow scrolling on palace-games.com
Modified: trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt (243218 => 243219)
--- trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt 2019-03-20 18:53:47 UTC (rev 243219)
@@ -35,26 +35,18 @@
Actual error data: [{"code":-32602,"message":"Parameter 'includeCommandLineAPI' has wrong type. It must be 'Boolean'."},{"code":-32602,"message":"Some arguments of method 'Runtime.evaluate' can't be processed"}]
-- Running test case: TestErrorCodeForSyncServerError
-Sending message: {"id":123,"method":"Database.getDatabaseTableNames","params":{"databaseId":"thisisNotADatabase"}}
+Sending message: {"id":123,"method":"Runtime.getProperties","params":{"objectId":"thisisNotAnId"}}
PASS: the backend should send a protocol error when receiving an invalid message.
PASS: the reported error should be "ServerError" (-32000)
Actual error code: -32000
-Actual error message: Database agent is not enabled
-Actual error data: [{"code":-32000,"message":"Database agent is not enabled"}]
+Actual error message: Could not find InjectedScript for objectId
+Actual error data: [{"code":-32000,"message":"Could not find InjectedScript for objectId"}]
-- Running test case: TestErrorCodeForAsyncServerError
-Sending message: {"id":123,"method":"Database.executeSQL","params":{"databaseId":"thisisNotADatabase","query":"asdf"}}
+Sending message: {"id":123,"method":"Runtime.awaitPromise","params":{"promiseObjectId":"thisisNotAnId"}}
PASS: the backend should send a protocol error when receiving an invalid message.
PASS: the reported error should be "ServerError" (-32000)
Actual error code: -32000
-Actual error message: Database agent is not enabled
-Actual error data: [{"code":-32000,"message":"Database agent is not enabled"}]
+Actual error message: Could not find InjectedScript for promiseObjectId
+Actual error data: [{"code":-32000,"message":"Could not find InjectedScript for promiseObjectId"}]
--- Running test case: CommandWithBadArgumentValue
-Sending message: {"id":123,"method":"Runtime.getProperties","params":{"objectId":"thisisNotAnId"}}
-PASS: the backend should send a protocol error when receiving an invalid message.
-PASS: the reported error should be "ServerError" (-32000)
-Actual error code: -32000
-Actual error message: Could not find InjectedScript for objectId
-Actual error data: [{"code":-32000,"message":"Could not find InjectedScript for objectId"}]
-
Modified: trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors.html (243218 => 243219)
--- trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors.html 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors.html 2019-03-20 18:53:47 UTC (rev 243219)
@@ -76,7 +76,7 @@
addErrorResponseTestCase({
name: "TestErrorCodeForSyncServerError",
description: "The backend should return a server error with the correct error code.",
- message: {id: 123, method: "Database.getDatabaseTableNames", params: {databaseId: "thisisNotADatabase"}},
+ message: {id: 123, method: "Runtime.getProperties", params: {objectId: "thisisNotAnId"}},
expectedError: "ServerError"
});
@@ -83,17 +83,10 @@
addErrorResponseTestCase({
name: "TestErrorCodeForAsyncServerError",
description: "The backend should return a server error with the correct error code.",
- message: {id: 123, method: "Database.executeSQL", params: {databaseId: "thisisNotADatabase", query: "asdf"}},
+ message: {id: 123, method: "Runtime.awaitPromise", params: {promiseObjectId: "thisisNotAnId"}},
expectedError: "ServerError"
});
- addErrorResponseTestCase({
- name: "CommandWithBadArgumentValue",
- description: "The backend should return an error if something went wrong when invoking the agent's method.",
- message: {id: 123, method: "Runtime.getProperties", params: {objectId: "thisisNotAnId"}},
- expectedError: "ServerError"
- });
-
suite.runTestCasesAndFinish();
}
</script>
Modified: trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect.html (243218 => 243219)
--- trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect.html 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect.html 2019-03-20 18:53:47 UTC (rev 243219)
@@ -25,6 +25,7 @@
let suite = ProtocolTest.createAsyncSuite("CommandLineAPI.prototype.inspect");
InspectorProtocol.awaitCommand({method: "Inspector.enable", params: {}})
+ InspectorProtocol.awaitCommand({method: "Database.enable", params: {}})
function addTestCase({name, description, _expression_}) {
suite.addTestCase({
Modified: trunk/Source/WebCore/ChangeLog (243218 => 243219)
--- trunk/Source/WebCore/ChangeLog 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/ChangeLog 2019-03-20 18:53:47 UTC (rev 243219)
@@ -1,3 +1,72 @@
+2019-03-20 Devin Rousso <[email protected]>
+
+ Web Inspector: Database: lazily create the agent
+ https://bugs.webkit.org/show_bug.cgi?id=195587
+ <rdar://problem/48791735>
+
+ Reviewed by Timothy Hatcher.
+
+ No change in functionality.
+
+ * inspector/agents/InspectorDatabaseAgent.h:
+ * inspector/agents/InspectorDatabaseAgent.cpp:
+ (WebCore::InspectorDatabaseAgent::didCommitLoad): Added.
+ (WebCore::InspectorDatabaseAgent::didOpenDatabase):
+ (WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
+ (WebCore::InspectorDatabaseAgent::enable):
+ (WebCore::InspectorDatabaseAgent::disable):
+ (WebCore::InspectorDatabaseAgent::getDatabaseTableNames):
+ (WebCore::InspectorDatabaseAgent::executeSQL):
+ (WebCore::InspectorDatabaseAgent::databaseId):
+ (WebCore::InspectorDatabaseAgent::findByFileName):
+ (WebCore::InspectorDatabaseAgent::databaseForId):
+ (WebCore::InspectorDatabaseAgent::clearResources): Deleted.
+ (WebCore::InspectorDatabaseAgent::~InspectorDatabaseAgent): Deleted.
+ * inspector/InspectorDatabaseResource.h:
+ (WebCore::InspectorDatabaseResource::database const):
+ (WebCore::InspectorDatabaseResource::setDatabase):
+ (WebCore::InspectorDatabaseResource::database): Deleted.
+ * inspector/InspectorDatabaseResource.cpp:
+ (WebCore::InspectorDatabaseResource::create):
+ (WebCore::InspectorDatabaseResource::InspectorDatabaseResource):
+ (WebCore::InspectorDatabaseResource::bind):
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::didOpenDatabase):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+ (WebCore::InspectorInstrumentation::didOpenDatabaseImpl):
+ Pass the `Database` as a reference instead of a pointer. Retrieve any information directly
+ from the `Database`, rather than using the arguments that were used to create it.
+
+ * Modules/webdatabase/Database.h:
+ (WebCore::Database::expectedVersion const): Deleted.
+ * Modules/webdatabase/Database.cpp:
+ (WebCore::Database::expectedVersion const): Added.
+ * Modules/webdatabase/DatabaseManager.cpp:
+ (WebCore::DatabaseManager::openDatabase):
+ * Modules/webdatabase/DatabaseTracker.h:
+ * Modules/webdatabase/DatabaseTracker.cpp:
+ (WebCore::DatabaseTracker::closeAllDatabases):
+ (WebCore::DatabaseTracker::openDatabases): Added.
+ Expose various values used by `InspectorDatabaseAgent` and `InspectorDatabaseResource`.
+
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ (WebCore::InspectorController::createLazyAgents):
+ * inspector/WorkerInspectorController.cpp:
+ (WebCore::WorkerInspectorController::WorkerInspectorController):
+
+ * inspector/CommandLineAPIHost.h:
+ (WebCore::CommandLineAPIHost::init):
+ * inspector/CommandLineAPIHost.cpp:
+ (WebCore::CommandLineAPIHost::disconnect):
+ (WebCore::CommandLineAPIHost::inspect):
+ (WebCore::CommandLineAPIHost::clearConsoleMessages):
+ (WebCore::CommandLineAPIHost::databaseId):
+ (WebCore::CommandLineAPIHost::storageId):
+ Rather than pass each agent individually, pass the entire `InstrumentingAgents` so that the
+ current agent can be used instead of whatever was initially created.
+
2019-03-20 Oriol Brufau <[email protected]>
[css-grid] Always consider baseline shim for the minimum contribution
Modified: trunk/Source/WebCore/Modules/webdatabase/Database.cpp (243218 => 243219)
--- trunk/Source/WebCore/Modules/webdatabase/Database.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/Modules/webdatabase/Database.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -618,6 +618,12 @@
return m_displayName.isolatedCopy();
}
+String Database::expectedVersion() const
+{
+ // Return a deep copy for ref counting thread safety
+ return m_expectedVersion.isolatedCopy();
+}
+
unsigned long long Database::estimatedSize() const
{
return m_estimatedSize;
Modified: trunk/Source/WebCore/Modules/webdatabase/Database.h (243218 => 243219)
--- trunk/Source/WebCore/Modules/webdatabase/Database.h 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/Modules/webdatabase/Database.h 2019-03-20 18:53:47 UTC (rev 243219)
@@ -88,6 +88,7 @@
// Internal engine support
String stringIdentifier() const;
String displayName() const;
+ String expectedVersion() const;
unsigned long long estimatedSize() const;
String fileName() const;
DatabaseDetails details() const;
@@ -133,7 +134,6 @@
bool getVersionFromDatabase(String& version, bool shouldCacheVersion = true);
bool setVersionInDatabase(const String& version, bool shouldCacheVersion = true);
void setExpectedVersion(const String&);
- const String& expectedVersion() const { return m_expectedVersion; }
String getCachedVersion() const;
void setCachedVersion(const String&);
bool getActualVersionForTransaction(String& version);
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp (243218 => 243219)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -211,7 +211,7 @@
auto databaseContext = this->databaseContext(context);
databaseContext->setHasOpenDatabases();
- InspectorInstrumentation::didOpenDatabase(&context, database.copyRef(), context.securityOrigin()->host(), name, expectedVersion);
+ InspectorInstrumentation::didOpenDatabase(*database);
if (database->isNew() && creationCallback.get()) {
LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for database %p\n", database.get());
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (243218 => 243219)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -289,19 +289,7 @@
void DatabaseTracker::closeAllDatabases(CurrentQueryBehavior currentQueryBehavior)
{
- Vector<Ref<Database>> openDatabases;
- {
- LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
- if (!m_openDatabaseMap)
- return;
- for (auto& nameMap : m_openDatabaseMap->values()) {
- for (auto& set : nameMap->values()) {
- for (auto& database : *set)
- openDatabases.append(*database);
- }
- }
- }
- for (auto& database : openDatabases) {
+ for (auto& database : openDatabases()) {
if (currentQueryBehavior == CurrentQueryBehavior::Interrupt)
database->interrupt();
database->close();
@@ -533,6 +521,24 @@
doneCreatingDatabase(database.securityOrigin(), database.stringIdentifier());
}
+Vector<Ref<Database>> DatabaseTracker::openDatabases()
+{
+ Vector<Ref<Database>> openDatabases;
+ {
+ LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
+
+ if (m_openDatabaseMap) {
+ for (auto& nameMap : m_openDatabaseMap->values()) {
+ for (auto& set : nameMap->values()) {
+ for (auto& database : *set)
+ openDatabases.append(*database);
+ }
+ }
+ }
+ }
+ return openDatabases;
+}
+
void DatabaseTracker::addOpenDatabase(Database& database)
{
LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h (243218 => 243219)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h 2019-03-20 18:53:47 UTC (rev 243219)
@@ -72,6 +72,7 @@
void setDatabaseDetails(const SecurityOriginData&, const String& name, const String& displayName, unsigned long long estimatedSize);
WEBCORE_EXPORT String fullPathForDatabase(const SecurityOriginData&, const String& name, bool createIfDoesNotExist);
+ Vector<Ref<Database>> openDatabases();
void addOpenDatabase(Database&);
void removeOpenDatabase(Database&);
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp (243218 => 243219)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -41,8 +41,8 @@
#include "JSEventListener.h"
#include "Pasteboard.h"
#include "Storage.h"
+#include "WebConsoleAgent.h"
#include <_javascript_Core/InspectorAgent.h>
-#include <_javascript_Core/InspectorConsoleAgent.h>
#include <_javascript_Core/JSCInlines.h>
#include <_javascript_Core/JSLock.h>
#include <_javascript_Core/ScriptValue.h>
@@ -69,22 +69,25 @@
void CommandLineAPIHost::disconnect()
{
- m_inspectorAgent = nullptr;
- m_consoleAgent = nullptr;
- m_databaseAgent = nullptr;
+
+ m_instrumentingAgents = nullptr;
}
void CommandLineAPIHost::inspect(JSC::ExecState& state, JSC::JSValue valueToInspect, JSC::JSValue hintsValue)
{
- if (!m_inspectorAgent)
+ if (!m_instrumentingAgents)
return;
+ auto* inspectorAgent = m_instrumentingAgents->inspectorAgent();
+ if (!inspectorAgent)
+ return;
+
RefPtr<JSON::Object> hintsObject;
if (!Inspector::toInspectorValue(state, hintsValue)->asObject(hintsObject))
return;
auto remoteObject = BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(Inspector::toInspectorValue(state, valueToInspect));
- m_inspectorAgent->inspect(WTFMove(remoteObject), WTFMove(hintsObject));
+ inspectorAgent->inspect(WTFMove(remoteObject), WTFMove(hintsObject));
}
CommandLineAPIHost::EventListenersRecord CommandLineAPIHost::getEventListeners(ExecState& state, EventTarget& target)
@@ -126,10 +129,15 @@
void CommandLineAPIHost::clearConsoleMessages()
{
- if (m_consoleAgent) {
- ErrorString unused;
- m_consoleAgent->clearMessages(unused);
- }
+ if (!m_instrumentingAgents)
+ return;
+
+ auto* consoleAgent = m_instrumentingAgents->webConsoleAgent();
+ if (!consoleAgent)
+ return;
+
+ ErrorString unused;
+ consoleAgent->clearMessages(unused);
}
void CommandLineAPIHost::copyText(const String& text)
@@ -159,8 +167,10 @@
String CommandLineAPIHost::databaseId(Database& database)
{
- if (m_databaseAgent)
- return m_databaseAgent->databaseId(database);
+ if (m_instrumentingAgents) {
+ if (auto* databaseAgent = m_instrumentingAgents->inspectorDatabaseAgent())
+ return databaseAgent->databaseId(database);
+ }
return { };
}
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.h (243218 => 243219)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2019-03-20 18:53:47 UTC (rev 243219)
@@ -29,6 +29,7 @@
#pragma once
+#include "InstrumentingAgents.h"
#include <_javascript_Core/PerGlobalObjectWrapperWorld.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
@@ -38,16 +39,10 @@
class JSValue;
}
-namespace Inspector {
-class InspectorAgent;
-class InspectorConsoleAgent;
-}
-
namespace WebCore {
class Database;
class EventTarget;
-class InspectorDatabaseAgent;
class JSDOMGlobalObject;
class Storage;
@@ -58,14 +53,9 @@
static Ref<CommandLineAPIHost> create();
~CommandLineAPIHost();
- void init(Inspector::InspectorAgent* inspectorAgent
- , Inspector::InspectorConsoleAgent* consoleAgent
- , InspectorDatabaseAgent* databaseAgent
- )
+ void init(RefPtr<InstrumentingAgents> instrumentingAgents)
{
- m_inspectorAgent = inspectorAgent;
- m_consoleAgent = consoleAgent;
- m_databaseAgent = databaseAgent;
+ m_instrumentingAgents = instrumentingAgents;
}
void disconnect();
@@ -102,10 +92,7 @@
private:
CommandLineAPIHost();
- Inspector::InspectorAgent* m_inspectorAgent { nullptr };
- Inspector::InspectorConsoleAgent* m_consoleAgent { nullptr };
- InspectorDatabaseAgent* m_databaseAgent { nullptr };
-
+ RefPtr<InstrumentingAgents> m_instrumentingAgents;
std::unique_ptr<InspectableObject> m_inspectedObject; // $0
Inspector::PerGlobalObjectWrapperWorld m_wrappers;
};
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (243218 => 243219)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -123,18 +123,13 @@
m_domAgent = domAgentPtr.get();
m_agents.append(WTFMove(domAgentPtr));
- auto databaseAgentPtr = std::make_unique<InspectorDatabaseAgent>(pageContext);
- InspectorDatabaseAgent* databaseAgent = databaseAgentPtr.get();
- m_agents.append(WTFMove(databaseAgentPtr));
+ auto consoleAgent = std::make_unique<PageConsoleAgent>(pageContext, m_domAgent);
+ m_instrumentingAgents->setWebConsoleAgent(consoleAgent.get());
+ m_agents.append(WTFMove(consoleAgent));
- auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, m_domAgent);
- WebConsoleAgent* consoleAgent = consoleAgentPtr.get();
- m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get());
- m_agents.append(WTFMove(consoleAgentPtr));
-
ASSERT(m_injectedScriptManager->commandLineAPIHost());
- if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
- commandLineAPIHost->init(m_inspectorAgent, consoleAgent, databaseAgent);
+ if (auto* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
+ commandLineAPIHost->init(m_instrumentingAgents.copyRef());
}
InspectorController::~InspectorController()
@@ -185,6 +180,7 @@
m_agents.append(std::make_unique<InspectorLayerTreeAgent>(pageContext));
m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext));
m_agents.append(std::make_unique<InspectorDOMStorageAgent>(pageContext));
+ m_agents.append(std::make_unique<InspectorDatabaseAgent>(pageContext));
#if ENABLE(INDEXED_DATABASE)
m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext, m_pageAgent));
#endif
Modified: trunk/Source/WebCore/inspector/InspectorDatabaseResource.cpp (243218 => 243219)
--- trunk/Source/WebCore/inspector/InspectorDatabaseResource.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/InspectorDatabaseResource.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -40,12 +40,12 @@
static int nextUnusedId = 1;
-Ref<InspectorDatabaseResource> InspectorDatabaseResource::create(RefPtr<Database>&& database, const String& domain, const String& name, const String& version)
+Ref<InspectorDatabaseResource> InspectorDatabaseResource::create(Database& database, const String& domain, const String& name, const String& version)
{
- return adoptRef(*new InspectorDatabaseResource(WTFMove(database), domain, name, version));
+ return adoptRef(*new InspectorDatabaseResource(database, domain, name, version));
}
-InspectorDatabaseResource::InspectorDatabaseResource(RefPtr<Database>&& database, const String& domain, const String& name, const String& version)
+InspectorDatabaseResource::InspectorDatabaseResource(Database& database, const String& domain, const String& name, const String& version)
: m_database(database)
, m_id(String::number(nextUnusedId++))
, m_domain(domain)
@@ -54,7 +54,7 @@
{
}
-void InspectorDatabaseResource::bind(Inspector::DatabaseFrontendDispatcher* databaseFrontendDispatcher)
+void InspectorDatabaseResource::bind(Inspector::DatabaseFrontendDispatcher& databaseFrontendDispatcher)
{
auto jsonObject = Inspector::Protocol::Database::Database::create()
.setId(m_id)
@@ -62,7 +62,7 @@
.setName(m_name)
.setVersion(m_version)
.release();
- databaseFrontendDispatcher->addDatabase(WTFMove(jsonObject));
+ databaseFrontendDispatcher.addDatabase(WTFMove(jsonObject));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorDatabaseResource.h (243218 => 243219)
--- trunk/Source/WebCore/inspector/InspectorDatabaseResource.h 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/InspectorDatabaseResource.h 2019-03-20 18:53:47 UTC (rev 243219)
@@ -41,17 +41,19 @@
class InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> {
public:
- static Ref<InspectorDatabaseResource> create(RefPtr<Database>&&, const String& domain, const String& name, const String& version);
+ static Ref<InspectorDatabaseResource> create(Database&, const String& domain, const String& name, const String& version);
- void bind(Inspector::DatabaseFrontendDispatcher*);
- Database* database() { return m_database.get(); }
- void setDatabase(RefPtr<Database>&& database) { m_database = WTFMove(database); }
+ void bind(Inspector::DatabaseFrontendDispatcher&);
+
+ Database& database() const { return m_database.get(); }
+ void setDatabase(Database& database) { m_database = database; }
+
String id() const { return m_id; }
private:
- InspectorDatabaseResource(RefPtr<Database>&&, const String& domain, const String& name, const String& version);
+ InspectorDatabaseResource(Database&, const String& domain, const String& name, const String& version);
- RefPtr<Database> m_database;
+ Ref<Database> m_database;
String m_id;
String m_domain;
String m_name;
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (243218 => 243219)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -35,7 +35,6 @@
#include "CachedResource.h"
#include "DOMWindow.h"
#include "DOMWrapperWorld.h"
-#include "Database.h"
#include "DocumentLoader.h"
#include "Event.h"
#include "Frame.h"
@@ -715,8 +714,8 @@
if (InspectorCSSAgent* cssAgent = instrumentingAgents.inspectorCSSAgent())
cssAgent->reset();
- if (InspectorDatabaseAgent* databaseAgent = instrumentingAgents.inspectorDatabaseAgent())
- databaseAgent->clearResources();
+ if (auto* databaseAgent = instrumentingAgents.inspectorDatabaseAgent())
+ databaseAgent->didCommitLoad();
if (InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent())
domAgent->setDocument(frame.document());
@@ -902,12 +901,10 @@
canvasAgent->consoleStartRecordingCanvas(context, exec, options);
}
-void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents& instrumentingAgents, RefPtr<Database>&& database, const String& domain, const String& name, const String& version)
+void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents& instrumentingAgents, Database& database)
{
- if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
- return;
- if (InspectorDatabaseAgent* dbAgent = instrumentingAgents.inspectorDatabaseAgent())
- dbAgent->didOpenDatabase(WTFMove(database), domain, name, version);
+ if (auto* databaseAgent = instrumentingAgents.inspectorDatabaseAgent())
+ databaseAgent->didOpenDatabase(database);
}
void InspectorInstrumentation::didDispatchDOMStorageEventImpl(InstrumentingAgents& instrumentingAgents, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (243218 => 243219)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2019-03-20 18:53:47 UTC (rev 243219)
@@ -35,6 +35,7 @@
#include "CallTracerTypes.h"
#include "CanvasBase.h"
#include "CanvasRenderingContext.h"
+#include "Database.h"
#include "DocumentThreadableLoader.h"
#include "Element.h"
#include "EventTarget.h"
@@ -68,7 +69,6 @@
class CharacterData;
class DOMWindow;
class DOMWrapperWorld;
-class Database;
class Document;
class DocumentLoader;
class EventListener;
@@ -240,7 +240,7 @@
static InspectorInstrumentationCookie willFireObserverCallback(ScriptExecutionContext&, const String& callbackType);
static void didFireObserverCallback(const InspectorInstrumentationCookie&);
- static void didOpenDatabase(ScriptExecutionContext*, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
+ static void didOpenDatabase(Database&);
static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
@@ -417,7 +417,7 @@
static InspectorInstrumentationCookie willFireObserverCallbackImpl(InstrumentingAgents&, const String&, ScriptExecutionContext&);
static void didFireObserverCallbackImpl(const InspectorInstrumentationCookie&);
- static void didOpenDatabaseImpl(InstrumentingAgents&, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
+ static void didOpenDatabaseImpl(InstrumentingAgents&, Database&);
static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
@@ -1172,10 +1172,11 @@
willDestroyCachedResourceImpl(cachedResource);
}
-inline void InspectorInstrumentation::didOpenDatabase(ScriptExecutionContext* context, RefPtr<Database>&& database, const String& domain, const String& name, const String& version)
+inline void InspectorInstrumentation::didOpenDatabase(Database& database)
{
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
- didOpenDatabaseImpl(*instrumentingAgents, WTFMove(database), domain, name, version);
+ FAST_RETURN_IF_NO_FRONTENDS(void());
+ if (auto* instrumentingAgents = instrumentingAgentsForContext(database.scriptExecutionContext()))
+ didOpenDatabaseImpl(*instrumentingAgents, database);
}
inline void InspectorInstrumentation::didDispatchDOMStorageEvent(Page& page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin)
Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.cpp (243218 => 243219)
--- trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -75,8 +75,8 @@
m_agents.append(std::make_unique<WorkerRuntimeAgent>(workerContext));
m_agents.append(WTFMove(consoleAgent));
- if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
- commandLineAPIHost->init(nullptr, m_instrumentingAgents->webConsoleAgent(), nullptr);
+ if (auto* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
+ commandLineAPIHost->init(m_instrumentingAgents.copyRef());
}
WorkerInspectorController::~WorkerInspectorController()
Modified: trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.cpp (243218 => 243219)
--- trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.cpp 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.cpp 2019-03-20 18:53:47 UTC (rev 243219)
@@ -31,6 +31,7 @@
#include "InspectorDatabaseAgent.h"
#include "Database.h"
+#include "DatabaseTracker.h"
#include "InspectorDatabaseResource.h"
#include "InstrumentingAgents.h"
#include "SQLError.h"
@@ -197,38 +198,30 @@
} // namespace
-void InspectorDatabaseAgent::didOpenDatabase(RefPtr<Database>&& database, const String& domain, const String& name, const String& version)
+void InspectorDatabaseAgent::didCommitLoad()
{
- if (auto* resource = findByFileName(database->fileName())) {
- resource->setDatabase(WTFMove(database));
+ m_resources.clear();
+}
+
+void InspectorDatabaseAgent::didOpenDatabase(Database& database)
+{
+ if (auto resource = findByFileName(database.fileName())) {
+ resource->setDatabase(database);
return;
}
- auto resource = InspectorDatabaseResource::create(WTFMove(database), domain, name, version);
+ auto resource = InspectorDatabaseResource::create(database, database.securityOrigin().host, database.stringIdentifier(), database.expectedVersion());
m_resources.add(resource->id(), resource.ptr());
- // Resources are only bound while visible.
- if (m_enabled)
- resource->bind(m_frontendDispatcher.get());
+ resource->bind(*m_frontendDispatcher);
}
-void InspectorDatabaseAgent::clearResources()
-{
- m_resources.clear();
-}
-
InspectorDatabaseAgent::InspectorDatabaseAgent(WebAgentContext& context)
: InspectorAgentBase("Database"_s, context)
, m_frontendDispatcher(std::make_unique<Inspector::DatabaseFrontendDispatcher>(context.frontendRouter))
, m_backendDispatcher(Inspector::DatabaseBackendDispatcher::create(context.backendDispatcher, this))
{
- m_instrumentingAgents.setInspectorDatabaseAgent(this);
}
-InspectorDatabaseAgent::~InspectorDatabaseAgent()
-{
- m_instrumentingAgents.setInspectorDatabaseAgent(nullptr);
-}
-
void InspectorDatabaseAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
{
}
@@ -241,25 +234,26 @@
void InspectorDatabaseAgent::enable(ErrorString&)
{
- if (m_enabled)
+ if (m_instrumentingAgents.inspectorDatabaseAgent() == this)
return;
- m_enabled = true;
- for (auto& resource : m_resources.values())
- resource->bind(m_frontendDispatcher.get());
+ m_instrumentingAgents.setInspectorDatabaseAgent(this);
+
+ for (auto& database : DatabaseTracker::singleton().openDatabases())
+ didOpenDatabase(database.get());
}
void InspectorDatabaseAgent::disable(ErrorString&)
{
- if (!m_enabled)
- return;
- m_enabled = false;
+ m_instrumentingAgents.setInspectorDatabaseAgent(nullptr);
+
+ m_resources.clear();
}
-void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString& error, const String& databaseId, RefPtr<JSON::ArrayOf<String>>& names)
+void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString& errorString, const String& databaseId, RefPtr<JSON::ArrayOf<String>>& names)
{
- if (!m_enabled) {
- error = "Database agent is not enabled"_s;
+ if (m_instrumentingAgents.inspectorDatabaseAgent() != this) {
+ errorString = "Database agent is not enabled"_s;
return;
}
@@ -273,8 +267,8 @@
void InspectorDatabaseAgent::executeSQL(const String& databaseId, const String& query, Ref<ExecuteSQLCallback>&& requestCallback)
{
- if (!m_enabled) {
- requestCallback->sendFailure("Database agent is not enabled");
+ if (m_instrumentingAgents.inspectorDatabaseAgent() != this) {
+ requestCallback->sendFailure("Database agent is not enabled"_s);
return;
}
@@ -292,7 +286,7 @@
String InspectorDatabaseAgent::databaseId(Database& database)
{
for (auto& resource : m_resources) {
- if (resource.value->database() == &database)
+ if (&resource.value->database() == &database)
return resource.key;
}
return String();
@@ -301,7 +295,7 @@
InspectorDatabaseResource* InspectorDatabaseAgent::findByFileName(const String& fileName)
{
for (auto& resource : m_resources.values()) {
- if (resource->database()->fileName() == fileName)
+ if (resource->database().fileName() == fileName)
return resource.get();
}
return nullptr;
@@ -309,10 +303,9 @@
Database* InspectorDatabaseAgent::databaseForId(const String& databaseId)
{
- auto* resource = m_resources.get(databaseId);
- if (!resource)
- return nullptr;
- return resource->database();
+ if (auto resource = m_resources.get(databaseId))
+ return &resource->database();
+ return nullptr;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.h (243218 => 243219)
--- trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.h 2019-03-20 18:26:40 UTC (rev 243218)
+++ trunk/Source/WebCore/inspector/agents/InspectorDatabaseAgent.h 2019-03-20 18:53:47 UTC (rev 243219)
@@ -33,6 +33,7 @@
#include <_javascript_Core/InspectorBackendDispatchers.h>
#include <_javascript_Core/InspectorFrontendDispatchers.h>
#include <wtf/HashMap.h>
+#include <wtf/Optional.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -47,12 +48,11 @@
WTF_MAKE_FAST_ALLOCATED;
public:
explicit InspectorDatabaseAgent(WebAgentContext&);
- virtual ~InspectorDatabaseAgent();
+ virtual ~InspectorDatabaseAgent() = default;
void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
- void clearResources();
// Called from the front-end.
void enable(ErrorString&) override;
@@ -63,7 +63,10 @@
// Called from the injected script.
String databaseId(Database&);
- void didOpenDatabase(RefPtr<Database>&&, const String& domain, const String& name, const String& version);
+ // InspectorInstrumentation
+ void didCommitLoad();
+ void didOpenDatabase(Database&);
+
private:
Database* databaseForId(const String& databaseId);
InspectorDatabaseResource* findByFileName(const String& fileName);
@@ -71,9 +74,7 @@
std::unique_ptr<Inspector::DatabaseFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::DatabaseBackendDispatcher> m_backendDispatcher;
- typedef HashMap<String, RefPtr<InspectorDatabaseResource>> DatabaseResourcesMap;
- DatabaseResourcesMap m_resources;
- bool m_enabled { false };
+ HashMap<String, RefPtr<InspectorDatabaseResource>> m_resources;
};
} // namespace WebCore