PublicURLManager.cpp [plain text]
#include "config.h"
#include "PublicURLManager.h"
#include "URL.h"
#include "URLRegistry.h"
#include <wtf/text/StringHash.h>
namespace WebCore {
std::unique_ptr<PublicURLManager> PublicURLManager::create(ScriptExecutionContext* context)
{
auto publicURLManager = std::make_unique<PublicURLManager>(context);
publicURLManager->suspendIfNeeded();
return publicURLManager;
}
PublicURLManager::PublicURLManager(ScriptExecutionContext* context)
: ActiveDOMObject(context)
, m_isStopped(false)
{
}
void PublicURLManager::registerURL(SecurityOrigin* origin, const URL& url, URLRegistrable& registrable)
{
if (m_isStopped)
return;
RegistryURLMap::iterator found = m_registryToURL.add(®istrable.registry(), URLSet()).iterator;
found->key->registerURL(origin, url, registrable);
found->value.add(url.string());
}
void PublicURLManager::revoke(const URL& url)
{
for (auto& registry : m_registryToURL) {
if (registry.value.contains(url.string())) {
registry.key->unregisterURL(url);
registry.value.remove(url.string());
break;
}
}
}
void PublicURLManager::stop()
{
if (m_isStopped)
return;
m_isStopped = true;
for (auto& registry : m_registryToURL) {
for (auto& url : registry.value)
registry.key->unregisterURL(URL(ParsedURLString, url));
}
m_registryToURL.clear();
}
bool PublicURLManager::canSuspendForDocumentSuspension() const
{
return true;
}
const char* PublicURLManager::activeDOMObjectName() const
{
return "PublicURLManager";
}
}