Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp

Issue 1621923002: [DevTools] Remove InspectorState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp
index 77789b4d4d061dcc28b05d7c88f48ecc2813d5e8..1f89f3f4d2e29d2d27b271185712c9b50e14bc2c 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp
@@ -30,7 +30,7 @@
#include "core/inspector/InspectorBaseAgent.h"
-#include "core/inspector/InspectorState.h"
+#include "core/inspector/JSONParser.h"
#include "wtf/PassOwnPtr.h"
namespace blink {
@@ -49,22 +49,30 @@ DEFINE_TRACE(InspectorAgent)
visitor->trace(m_instrumentingAgents);
}
-void InspectorAgent::appended(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
+void InspectorAgent::appended(InstrumentingAgents* instrumentingAgents)
{
m_instrumentingAgents = instrumentingAgents;
- m_state = inspectorState;
init();
}
-InspectorAgentRegistry::InspectorAgentRegistry(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState)
+void InspectorAgent::setState(PassRefPtr<JSONObject> state)
+{
+ m_state = state;
+}
+
+InspectorAgentRegistry::InspectorAgentRegistry(InstrumentingAgents* instrumentingAgents)
: m_instrumentingAgents(instrumentingAgents)
- , m_inspectorState(inspectorState)
+ , m_state(JSONObject::create())
{
}
void InspectorAgentRegistry::append(PassOwnPtrWillBeRawPtr<InspectorAgent> agent)
{
- agent->appended(m_instrumentingAgents, m_inspectorState->createAgentState(agent->name()));
+ ASSERT(m_state->find(agent->name()) == m_state->end());
+ RefPtr<JSONObject> agentState = JSONObject::create();
+ m_state->setObject(agent->name(), agentState);
+ agent->setState(agentState);
+ agent->appended(m_instrumentingAgents);
m_agents.append(agent);
}
@@ -80,12 +88,32 @@ void InspectorAgentRegistry::clearFrontend()
m_agents[i]->clearFrontend();
}
-void InspectorAgentRegistry::restore()
+void InspectorAgentRegistry::restore(const String& savedState)
{
+ RefPtr<JSONValue> state = parseJSON(savedState);
+ if (state)
+ m_state = state->asObject();
+ if (!m_state)
+ m_state = JSONObject::create();
+
+ for (size_t i = 0; i < m_agents.size(); i++) {
+ RefPtr<JSONObject> agentState = m_state->getObject(m_agents[i]->name());
+ if (!agentState) {
+ agentState = JSONObject::create();
+ m_state->setObject(m_agents[i]->name(), agentState);
+ }
+ m_agents[i]->setState(agentState);
+ }
+
for (size_t i = 0; i < m_agents.size(); i++)
m_agents[i]->restore();
}
+String InspectorAgentRegistry::state()
+{
+ return m_state->toJSONString();
+}
+
void InspectorAgentRegistry::registerInDispatcher(InspectorBackendDispatcher* dispatcher)
{
for (size_t i = 0; i < m_agents.size(); i++)

Powered by Google App Engine
This is Rietveld 408576698