Diff
Modified: trunk/Source/WebCore/ChangeLog (243157 => 243158)
--- trunk/Source/WebCore/ChangeLog 2019-03-19 18:54:58 UTC (rev 243157)
+++ trunk/Source/WebCore/ChangeLog 2019-03-19 19:11:07 UTC (rev 243158)
@@ -1,3 +1,38 @@
+2019-03-19 Devin Rousso <[email protected]>
+
+ Web Inspector: DOMStorage: lazily create the agent
+ https://bugs.webkit.org/show_bug.cgi?id=195588
+ <rdar://problem/48791878>
+
+ Reviewed by Joseph Pecoraro.
+
+ No change in functionality.
+
+ Make functions used by `CommandLineAPIHost` static so that an `InspectorDOMStorageAgent`
+ doesn't need to be created to call them.
+
+ * inspector/agents/InspectorDOMStorageAgent.h:
+ * inspector/agents/InspectorDOMStorageAgent.cpp:
+ (WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent):
+ (WebCore::InspectorDOMStorageAgent::enable):
+ (WebCore::InspectorDOMStorageAgent::disable):
+ (WebCore::InspectorDOMStorageAgent::storageId):
+ (WebCore::InspectorDOMStorageAgent::didDispatchDOMStorageEvent):
+ (WebCore::InspectorDOMStorageAgent::findStorageArea):
+ (WebCore::InspectorDOMStorageAgent::~InspectorDOMStorageAgent): Deleted.
+
+ * inspector/CommandLineAPIHost.h:
+ (WebCore::CommandLineAPIHost::init):
+ * inspector/CommandLineAPIHost.cpp:
+ (WebCore::CommandLineAPIHost::disconnect):
+ (WebCore::CommandLineAPIHost::storageId):
+
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ (WebCore::InspectorController::createLazyAgents):
+ * inspector/WorkerInspectorController.cpp:
+ (WebCore::WorkerInspectorController::WorkerInspectorController):
+
2019-03-19 Youenn Fablet <[email protected]>
REGRESSION: Layout Test http/tests/security/cross-origin-indexeddb.html is crashing
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp (243157 => 243158)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2019-03-19 18:54:58 UTC (rev 243157)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2019-03-19 19:11:07 UTC (rev 243158)
@@ -71,7 +71,6 @@
{
m_inspectorAgent = nullptr;
m_consoleAgent = nullptr;
- m_domStorageAgent = nullptr;
m_databaseAgent = nullptr;
}
@@ -167,9 +166,7 @@
String CommandLineAPIHost::storageId(Storage& storage)
{
- if (m_domStorageAgent)
- return m_domStorageAgent->storageId(storage);
- return { };
+ return InspectorDOMStorageAgent::storageId(storage);
}
JSValue CommandLineAPIHost::wrapper(ExecState* exec, JSDOMGlobalObject* globalObject)
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.h (243157 => 243158)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2019-03-19 18:54:58 UTC (rev 243157)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2019-03-19 19:11:07 UTC (rev 243158)
@@ -47,7 +47,6 @@
class Database;
class EventTarget;
-class InspectorDOMStorageAgent;
class InspectorDatabaseAgent;
class JSDOMGlobalObject;
class Storage;
@@ -61,13 +60,11 @@
void init(Inspector::InspectorAgent* inspectorAgent
, Inspector::InspectorConsoleAgent* consoleAgent
- , InspectorDOMStorageAgent* domStorageAgent
, InspectorDatabaseAgent* databaseAgent
)
{
m_inspectorAgent = inspectorAgent;
m_consoleAgent = consoleAgent;
- m_domStorageAgent = domStorageAgent;
m_databaseAgent = databaseAgent;
}
@@ -107,7 +104,6 @@
Inspector::InspectorAgent* m_inspectorAgent { nullptr };
Inspector::InspectorConsoleAgent* m_consoleAgent { nullptr };
- InspectorDOMStorageAgent* m_domStorageAgent { nullptr };
InspectorDatabaseAgent* m_databaseAgent { nullptr };
std::unique_ptr<InspectableObject> m_inspectedObject; // $0
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (243157 => 243158)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2019-03-19 18:54:58 UTC (rev 243157)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2019-03-19 19:11:07 UTC (rev 243158)
@@ -127,10 +127,6 @@
InspectorDatabaseAgent* databaseAgent = databaseAgentPtr.get();
m_agents.append(WTFMove(databaseAgentPtr));
- auto domStorageAgentPtr = std::make_unique<InspectorDOMStorageAgent>(pageContext, m_pageAgent);
- InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get();
- m_agents.append(WTFMove(domStorageAgentPtr));
-
auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(pageContext);
m_instrumentingAgents->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
m_agents.append(WTFMove(scriptProfilerAgentPtr));
@@ -142,7 +138,7 @@
ASSERT(m_injectedScriptManager->commandLineAPIHost());
if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
- commandLineAPIHost->init(m_inspectorAgent, consoleAgent, domStorageAgent, databaseAgent);
+ commandLineAPIHost->init(m_inspectorAgent, consoleAgent, databaseAgent);
}
InspectorController::~InspectorController()
@@ -192,6 +188,7 @@
m_agents.append(std::make_unique<InspectorApplicationCacheAgent>(pageContext, m_pageAgent));
m_agents.append(std::make_unique<InspectorLayerTreeAgent>(pageContext));
m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext));
+ m_agents.append(std::make_unique<InspectorDOMStorageAgent>(pageContext));
#if ENABLE(INDEXED_DATABASE)
m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext, m_pageAgent));
#endif
@@ -198,8 +195,8 @@
#if ENABLE(RESOURCE_USAGE)
m_agents.append(std::make_unique<InspectorCPUProfilerAgent>(pageContext));
m_agents.append(std::make_unique<InspectorMemoryAgent>(pageContext));
+#endif
m_agents.append(std::make_unique<PageHeapAgent>(pageContext));
-#endif
m_agents.append(std::make_unique<PageAuditAgent>(pageContext));
m_agents.append(std::make_unique<InspectorCanvasAgent>(pageContext));
m_agents.append(std::make_unique<InspectorTimelineAgent>(pageContext));
Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.cpp (243157 => 243158)
--- trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2019-03-19 18:54:58 UTC (rev 243157)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2019-03-19 19:11:07 UTC (rev 243158)
@@ -77,7 +77,7 @@
m_agents.append(WTFMove(consoleAgent));
if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
- commandLineAPIHost->init(nullptr, m_instrumentingAgents->webConsoleAgent(), nullptr, nullptr);
+ commandLineAPIHost->init(nullptr, m_instrumentingAgents->webConsoleAgent(), nullptr);
}
WorkerInspectorController::~WorkerInspectorController()
Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp (243157 => 243158)
--- trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp 2019-03-19 18:54:58 UTC (rev 243157)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp 2019-03-19 19:11:07 UTC (rev 243158)
@@ -54,20 +54,13 @@
using namespace Inspector;
-InspectorDOMStorageAgent::InspectorDOMStorageAgent(WebAgentContext& context, InspectorPageAgent* pageAgent)
+InspectorDOMStorageAgent::InspectorDOMStorageAgent(WebAgentContext& context)
: InspectorAgentBase("DOMStorage"_s, context)
, m_frontendDispatcher(std::make_unique<Inspector::DOMStorageFrontendDispatcher>(context.frontendRouter))
, m_backendDispatcher(Inspector::DOMStorageBackendDispatcher::create(context.backendDispatcher, this))
- , m_pageAgent(pageAgent)
{
- m_instrumentingAgents.setInspectorDOMStorageAgent(this);
}
-InspectorDOMStorageAgent::~InspectorDOMStorageAgent()
-{
- m_instrumentingAgents.setInspectorDOMStorageAgent(nullptr);
-}
-
void InspectorDOMStorageAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
{
}
@@ -80,12 +73,12 @@
void InspectorDOMStorageAgent::enable(ErrorString&)
{
- m_enabled = true;
+ m_instrumentingAgents.setInspectorDOMStorageAgent(this);
}
void InspectorDOMStorageAgent::disable(ErrorString&)
{
- m_enabled = false;
+ m_instrumentingAgents.setInspectorDOMStorageAgent(nullptr);
}
void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString& errorString, const JSON::Object& storageId, RefPtr<JSON::ArrayOf<JSON::ArrayOf<String>>>& items)
@@ -147,7 +140,7 @@
ASSERT(window);
Ref<SecurityOrigin> securityOrigin = document->securityOrigin();
bool isLocalStorage = window->optionalLocalStorage() == &storage;
- return storageId(securityOrigin.ptr(), isLocalStorage)->toJSONString();
+ return InspectorDOMStorageAgent::storageId(securityOrigin.ptr(), isLocalStorage)->toJSONString();
}
RefPtr<Inspector::Protocol::DOMStorage::StorageId> InspectorDOMStorageAgent::storageId(SecurityOrigin* securityOrigin, bool isLocalStorage)
@@ -160,11 +153,8 @@
void InspectorDOMStorageAgent::didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin)
{
- if (!m_enabled)
- return;
+ RefPtr<Inspector::Protocol::DOMStorage::StorageId> id = InspectorDOMStorageAgent::storageId(securityOrigin, storageType == StorageType::Local);
- RefPtr<Inspector::Protocol::DOMStorage::StorageId> id = storageId(securityOrigin, storageType == StorageType::Local);
-
if (key.isNull())
m_frontendDispatcher->domStorageItemsCleared(id);
else if (newValue.isNull())
@@ -188,7 +178,14 @@
return nullptr;
}
- targetFrame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
+ auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+ ASSERT(pageAgent);
+ if (!pageAgent) {
+ errorString = "Missing Page agent"_s;
+ return nullptr;
+ }
+
+ targetFrame = pageAgent->findFrameWithSecurityOrigin(securityOrigin);
if (!targetFrame) {
errorString = "Frame not found for the given security origin"_s;
return nullptr;
@@ -195,8 +192,8 @@
}
if (!isLocalStorage)
- return m_pageAgent->page().sessionStorage()->storageArea(targetFrame->document()->securityOrigin().data());
- return m_pageAgent->page().storageNamespaceProvider().localStorageArea(*targetFrame->document());
+ return pageAgent->page().sessionStorage()->storageArea(targetFrame->document()->securityOrigin().data());
+ return pageAgent->page().storageNamespaceProvider().localStorageArea(*targetFrame->document());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h (243157 => 243158)
--- trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h 2019-03-19 18:54:58 UTC (rev 243157)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h 2019-03-19 19:11:07 UTC (rev 243158)
@@ -41,7 +41,6 @@
namespace WebCore {
class Frame;
-class InspectorPageAgent;
class Page;
class SecurityOrigin;
class Storage;
@@ -52,8 +51,8 @@
WTF_MAKE_NONCOPYABLE(InspectorDOMStorageAgent);
WTF_MAKE_FAST_ALLOCATED;
public:
- InspectorDOMStorageAgent(WebAgentContext&, InspectorPageAgent*);
- virtual ~InspectorDOMStorageAgent();
+ InspectorDOMStorageAgent(WebAgentContext&);
+ virtual ~InspectorDOMStorageAgent() = default;
void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
@@ -66,8 +65,8 @@
void removeDOMStorageItem(ErrorString&, const JSON::Object& storageId, const String& key) override;
// Called from the injected script.
- String storageId(Storage&);
- RefPtr<Inspector::Protocol::DOMStorage::StorageId> storageId(SecurityOrigin*, bool isLocalStorage);
+ static String storageId(Storage&);
+ static RefPtr<Inspector::Protocol::DOMStorage::StorageId> storageId(SecurityOrigin*, bool isLocalStorage);
// InspectorInstrumentation
void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
@@ -77,9 +76,6 @@
std::unique_ptr<Inspector::DOMStorageFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::DOMStorageBackendDispatcher> m_backendDispatcher;
- InspectorPageAgent* m_pageAgent { nullptr };
-
- bool m_enabled { false };
};
} // namespace WebCore