This source file includes following definitions.
- create
- m_isStopped
- registerURL
- revoke
- revoke
- stop
#include "config.h"
#include "core/html/PublicURLManager.h"
#include "core/fetch/MemoryCache.h"
#include "core/html/URLRegistry.h"
#include "platform/weborigin/KURL.h"
#include "wtf/Vector.h"
#include "wtf/text/StringHash.h"
namespace WebCore {
PassOwnPtr<PublicURLManager> PublicURLManager::create(ExecutionContext* context)
{
OwnPtr<PublicURLManager> publicURLManager(adoptPtr(new PublicURLManager(context)));
publicURLManager->suspendIfNeeded();
return publicURLManager.release();
}
PublicURLManager::PublicURLManager(ExecutionContext* context)
: ActiveDOMObject(context)
, m_isStopped(false)
{
}
void PublicURLManager::registerURL(SecurityOrigin* origin, const KURL& url, URLRegistrable* registrable, const String& uuid)
{
if (m_isStopped)
return;
RegistryURLMap::ValueType* found = m_registryToURL.add(®istrable->registry(), URLMap()).storedValue;
found->key->registerURL(origin, url, registrable);
found->value.add(url.string(), uuid);
}
void PublicURLManager::revoke(const KURL& 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::revoke(const String& uuid)
{
Vector<String> urlsToRemove;
for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) {
URLRegistry* registry = i->key;
URLMap& registeredURLs = i->value;
for (URLMap::iterator j = registeredURLs.begin(); j != registeredURLs.end(); ++j) {
if (uuid == j->value) {
KURL url(ParsedURLString, j->key);
MemoryCache::removeURLFromCache(executionContext(), url);
registry->unregisterURL(url);
urlsToRemove.append(j->key);
}
}
for (unsigned j = 0; j < urlsToRemove.size(); j++)
registeredURLs.remove(urlsToRemove[j]);
urlsToRemove.clear();
}
}
void PublicURLManager::stop()
{
if (m_isStopped)
return;
m_isStopped = true;
for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) {
for (URLMap::iterator j = i->value.begin(); j != i->value.end(); ++j)
i->key->unregisterURL(KURL(ParsedURLString, j->key));
}
m_registryToURL.clear();
}
}