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 (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) {
if (i->value.contains(url.string())) {
i->key->unregisterURL(url);
i->value.remove(url.string());
break;
}
}
}
void PublicURLManager::stop()
{
if (m_isStopped)
return;
m_isStopped = true;
for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) {
for (URLSet::iterator j = i->value.begin(); j != i->value.end(); ++j)
i->key->unregisterURL(URL(ParsedURLString, *j));
}
m_registryToURL.clear();
}
}