Index: Source/core/html/PublicURLManager.cpp |
diff --git a/Source/core/html/PublicURLManager.cpp b/Source/core/html/PublicURLManager.cpp |
index 09157de9df7ad8f906cb24ffd2b51e96549bdbba..72d1de411a8fff4e268f216e1fb6613f1cc230ef 100644 |
--- a/Source/core/html/PublicURLManager.cpp |
+++ b/Source/core/html/PublicURLManager.cpp |
@@ -29,6 +29,7 @@ |
#include "core/html/URLRegistry.h" |
#include "platform/weborigin/KURL.h" |
+#include "wtf/Vector.h" |
#include "wtf/text/StringHash.h" |
namespace WebCore { |
@@ -46,14 +47,14 @@ PublicURLManager::PublicURLManager(ExecutionContext* context) |
{ |
} |
-void PublicURLManager::registerURL(SecurityOrigin* origin, const KURL& url, URLRegistrable* registrable) |
+void PublicURLManager::registerURL(SecurityOrigin* origin, const KURL& url, URLRegistrable* registrable, const String& uuid) |
{ |
if (m_isStopped) |
return; |
- RegistryURLMap::iterator found = m_registryToURL.add(®istrable->registry(), URLSet()).iterator; |
+ RegistryURLMap::iterator found = m_registryToURL.add(®istrable->registry(), URLMap()).iterator; |
found->key->registerURL(origin, url, registrable); |
- found->value.add(url.string()); |
+ found->value.add(url.string(), uuid); |
} |
void PublicURLManager::revoke(const KURL& url) |
@@ -67,6 +68,25 @@ void PublicURLManager::revoke(const KURL& url) |
} |
} |
+void PublicURLManager::revoke(const String& uuid) |
+{ |
+ // A linear scan; revoking by UUID is assumed rare. |
+ Vector<String> removableKeys; |
+ for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) { |
+ for (URLMap::iterator j = i->value.begin(); j != i->value.end(); ++j) { |
+ if (uuid == j->value) { |
+ i->key->unregisterURL(KURL(ParsedURLString, j->key)); |
+ removableKeys.append(j->key); |
+ } |
+ } |
+ if (removableKeys.size()) { |
+ for (unsigned j = 0; j < removableKeys.size(); j++) |
+ i->value.remove(removableKeys[j]); |
+ removableKeys.clear(); |
+ } |
kinuko
2014/02/12 06:11:20
It might be slightly more readable if we just main
sof
2014/02/12 06:56:47
It would have to be UUID to a set of URLs; would t
kinuko
2014/02/12 12:52:00
I guessed in general this map'd be relatively smal
sof
2014/02/13 09:59:57
Thanks, I've tried to improve readability - please
|
+ } |
+} |
+ |
void PublicURLManager::stop() |
{ |
if (m_isStopped) |
@@ -74,8 +94,8 @@ void PublicURLManager::stop() |
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(KURL(ParsedURLString, *j)); |
+ for (URLMap::iterator j = i->value.begin(); j != i->value.end(); ++j) |
+ i->key->unregisterURL(KURL(ParsedURLString, j->key)); |
} |
m_registryToURL.clear(); |