summaryrefslogtreecommitdiff
path: root/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/fileapi/ThreadableBlobRegistry.cpp')
-rw-r--r--Source/WebCore/fileapi/ThreadableBlobRegistry.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp b/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
index 2ec421bac..8a41285fc 100644
--- a/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
+++ b/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
@@ -34,7 +34,15 @@
#include "BlobData.h"
#include "BlobRegistry.h"
+#include "BlobURL.h"
+#include "SecurityOrigin.h"
+#include <wtf/HashMap.h>
#include <wtf/MainThread.h>
+#include <wtf/RefPtr.h>
+#include <wtf/ThreadSpecific.h>
+#include <wtf/text/StringHash.h>
+
+using WTF::ThreadSpecific;
namespace WebCore {
@@ -64,6 +72,13 @@ struct BlobRegistryContext {
#if ENABLE(BLOB)
+typedef HashMap<String, RefPtr<SecurityOrigin> > BlobUrlOriginMap;
+static ThreadSpecific<BlobUrlOriginMap>& originMap()
+{
+ AtomicallyInitializedStatic(ThreadSpecific<BlobUrlOriginMap>*, map = new ThreadSpecific<BlobUrlOriginMap>);
+ return *map;
+}
+
static void registerBlobURLTask(void* context)
{
OwnPtr<BlobRegistryContext> blobRegistryContext = adoptPtr(static_cast<BlobRegistryContext*>(context));
@@ -86,8 +101,12 @@ static void registerBlobURLFromTask(void* context)
blobRegistry().registerBlobURL(blobRegistryContext->url, blobRegistryContext->srcURL);
}
-void ThreadableBlobRegistry::registerBlobURL(const KURL& url, const KURL& srcURL)
+void ThreadableBlobRegistry::registerBlobURL(SecurityOrigin* origin, const KURL& url, const KURL& srcURL)
{
+ // If the blob URL contains null origin, as in the context with unique security origin or file URL, save the mapping between url and origin so that the origin can be retrived when doing security origin check.
+ if (origin && BlobURL::getOrigin(url) == "null")
+ originMap()->add(url.string(), origin);
+
if (isMainThread())
blobRegistry().registerBlobURL(url, srcURL);
else {
@@ -104,6 +123,9 @@ static void unregisterBlobURLTask(void* context)
void ThreadableBlobRegistry::unregisterBlobURL(const KURL& url)
{
+ if (BlobURL::getOrigin(url) == "null")
+ originMap()->remove(url.string());
+
if (isMainThread())
blobRegistry().unregisterBlobURL(url);
else {
@@ -112,19 +134,30 @@ void ThreadableBlobRegistry::unregisterBlobURL(const KURL& url)
}
}
+PassRefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const KURL& url)
+{
+ return originMap()->get(url.string());
+}
+
#else
void ThreadableBlobRegistry::registerBlobURL(const KURL&, PassOwnPtr<BlobData>)
{
}
-void ThreadableBlobRegistry::registerBlobURL(const KURL&, const KURL&)
+void ThreadableBlobRegistry::registerBlobURL(SecurityOrigin*, const KURL&, const KURL&)
{
}
void ThreadableBlobRegistry::unregisterBlobURL(const KURL&)
{
}
+
+PassRefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const KURL& url)
+{
+ return 0;
+}
+
#endif // ENABL(BLOB)
} // namespace WebCore