diff options
Diffstat (limited to 'Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp')
-rw-r--r-- | Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp b/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp index e0d9ede15..b5e34741c 100644 --- a/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp +++ b/Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,39 +27,52 @@ #include "config.h" #include "InspectorAgentRegistry.h" -#if ENABLE(INSPECTOR) - #include "InspectorAgentBase.h" namespace Inspector { -InspectorAgentRegistry::InspectorAgentRegistry() +AgentRegistry::AgentRegistry() { } -void InspectorAgentRegistry::append(std::unique_ptr<InspectorAgentBase> agent) +AgentRegistry::~AgentRegistry() { - m_agents.append(std::move(agent)); + // Allow agents to remove cross-references to other agents that would otherwise + // make it difficult to establish a correct destruction order for all agents. + for (auto& agent : m_agents) + agent->discardAgent(); } -void InspectorAgentRegistry::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher) +void AgentRegistry::append(std::unique_ptr<InspectorAgentBase> agent) { - for (size_t i = 0; i < m_agents.size(); i++) - m_agents[i]->didCreateFrontendAndBackend(frontendChannel, backendDispatcher); + m_agents.append(WTFMove(agent)); } -void InspectorAgentRegistry::willDestroyFrontendAndBackend(InspectorDisconnectReason reason) +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +void AgentRegistry::appendExtraAgent(std::unique_ptr<InspectorAgentBase> agent) { - for (size_t i = 0; i < m_agents.size(); i++) - m_agents[i]->willDestroyFrontendAndBackend(reason); + m_extraDomains.append(agent->domainName()); + + append(WTFMove(agent)); } +#endif -void InspectorAgentRegistry::discardAgents() +void AgentRegistry::didCreateFrontendAndBackend(FrontendRouter* frontendRouter, BackendDispatcher* backendDispatcher) { - for (size_t i = 0; i < m_agents.size(); i++) - m_agents[i]->discardAgent(); + for (auto& agent : m_agents) + agent->didCreateFrontendAndBackend(frontendRouter, backendDispatcher); } -} // namespace Inspector +void AgentRegistry::willDestroyFrontendAndBackend(DisconnectReason reason) +{ + for (auto& agent : m_agents) + agent->willDestroyFrontendAndBackend(reason); +} -#endif // ENABLE(INSPECTOR) +void AgentRegistry::discardValues() +{ + for (auto& agent : m_agents) + agent->discardValues(); +} + +} // namespace Inspector |