Index: Source/core/fileapi/Blob.cpp |
diff --git a/Source/core/fileapi/Blob.cpp b/Source/core/fileapi/Blob.cpp |
index 4fa8e1f947b7f35a4758164e9c749141686ff264..ddca8af746aef8afc4a1dcdb19c1dbfa3de18c9e 100644 |
--- a/Source/core/fileapi/Blob.cpp |
+++ b/Source/core/fileapi/Blob.cpp |
@@ -31,6 +31,8 @@ |
#include "config.h" |
#include "core/fileapi/Blob.h" |
+#include "core/dom/DOMURL.h" |
+#include "core/dom/ExecutionContext.h" |
#include "platform/blob/BlobRegistry.h" |
#include "platform/blob/BlobURL.h" |
@@ -46,10 +48,11 @@ public: |
static URLRegistry& registry(); |
}; |
-void BlobURLRegistry::registerURL(SecurityOrigin* origin, const KURL& publicURL, URLRegistrable* blob) |
+void BlobURLRegistry::registerURL(SecurityOrigin* origin, const KURL& publicURL, URLRegistrable* registrableObject) |
{ |
- ASSERT(&blob->registry() == this); |
- BlobRegistry::registerPublicBlobURL(origin, publicURL, static_cast<Blob*>(blob)->blobDataHandle()); |
+ ASSERT(®istrableObject->registry() == this); |
+ Blob* blob = static_cast<Blob*>(registrableObject); |
+ BlobRegistry::registerPublicBlobURL(origin, publicURL, blob->blobDataHandle()); |
} |
void BlobURLRegistry::unregisterURL(const KURL& publicURL) |
@@ -67,6 +70,7 @@ URLRegistry& BlobURLRegistry::registry() |
Blob::Blob(PassRefPtr<BlobDataHandle> dataHandle) |
: m_blobDataHandle(dataHandle) |
+ , m_hasBeenClosed(false) |
{ |
ScriptWrappable::init(this); |
} |
@@ -111,6 +115,25 @@ PassRefPtr<Blob> Blob::slice(long long start, long long end, const String& conte |
return Blob::create(BlobDataHandle::create(blobData.release(), length)); |
} |
+void Blob::close(ExecutionContext* executionContext) |
+{ |
+ if (!hasBeenClosed()) { |
+ // Dereferencing a Blob that has been closed should result in |
+ // a network error. Revoke URLs registered against it through |
+ // its UUID. |
+ DOMURL::revokeObjectUUID(executionContext, uuid()); |
+ |
+ // A closed Blob should have size zero, which most consumers |
+ // will treat as an empty Blob. The exception being the FileReader |
+ // read operations which will throw. |
+ // FIXME: spec not yet set in stone in this regard, track updates to it (http://crbug.com/344820.) |
+ OwnPtr<BlobData> blobData = BlobData::create(); |
+ blobData->setContentType(type()); |
+ m_blobDataHandle = BlobDataHandle::create(blobData.release(), 0); |
+ m_hasBeenClosed = true; |
+ } |
+} |
+ |
void Blob::appendTo(BlobData& blobData) const |
{ |
blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); |
@@ -121,5 +144,4 @@ URLRegistry& Blob::registry() const |
return BlobURLRegistry::registry(); |
} |
- |
} // namespace WebCore |