| Index: Source/core/fileapi/Blob.cpp
|
| diff --git a/Source/core/fileapi/Blob.cpp b/Source/core/fileapi/Blob.cpp
|
| index f93b428a80231f56d3aabcb259fea3a26356e20c..dfb19cce89b5a1987f3e6b4ec5dfcc42bd9bc9b0 100644
|
| --- a/Source/core/fileapi/Blob.cpp
|
| +++ b/Source/core/fileapi/Blob.cpp
|
| @@ -37,6 +37,8 @@
|
|
|
| namespace WebCore {
|
|
|
| +namespace {
|
| +
|
| class BlobURLRegistry : public URLRegistry {
|
| public:
|
| virtual void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*) OVERRIDE;
|
| @@ -45,16 +47,15 @@ public:
|
| static URLRegistry& registry();
|
| };
|
|
|
| -
|
| void BlobURLRegistry::registerURL(SecurityOrigin* origin, const KURL& publicURL, URLRegistrable* blob)
|
| {
|
| ASSERT(&blob->registry() == this);
|
| - BlobRegistry::registerBlobURL(origin, publicURL, static_cast<Blob*>(blob)->url());
|
| + BlobRegistry::registerPublicBlobURL(origin, publicURL, static_cast<Blob*>(blob)->blobDataHandle());
|
| }
|
|
|
| -void BlobURLRegistry::unregisterURL(const KURL& url)
|
| +void BlobURLRegistry::unregisterURL(const KURL& publicURL)
|
| {
|
| - BlobRegistry::unregisterBlobURL(url);
|
| + BlobRegistry::revokePublicBlobURL(publicURL);
|
| }
|
|
|
| URLRegistry& BlobURLRegistry::registry()
|
| @@ -63,44 +64,16 @@ URLRegistry& BlobURLRegistry::registry()
|
| return instance;
|
| }
|
|
|
| +} // namespace
|
|
|
| -Blob::Blob()
|
| - : m_size(0)
|
| +Blob::Blob(PassRefPtr<BlobDataHandle> dataHandle)
|
| + : m_blobDataHandle(dataHandle)
|
| {
|
| ScriptWrappable::init(this);
|
| - OwnPtr<BlobData> blobData = BlobData::create();
|
| -
|
| - // Create a new internal URL and register it with the provided blob data.
|
| - m_internalURL = BlobURL::createInternalURL();
|
| - BlobRegistry::registerBlobURL(m_internalURL, blobData.release());
|
| -}
|
| -
|
| -Blob::Blob(PassOwnPtr<BlobData> blobData, long long size)
|
| - : m_type(blobData->contentType())
|
| - , m_size(size)
|
| -{
|
| - ASSERT(blobData);
|
| - ScriptWrappable::init(this);
|
| -
|
| - // Create a new internal URL and register it with the provided blob data.
|
| - m_internalURL = BlobURL::createInternalURL();
|
| - BlobRegistry::registerBlobURL(m_internalURL, blobData);
|
| -}
|
| -
|
| -Blob::Blob(const KURL& srcURL, const String& type, long long size)
|
| - : m_type(type)
|
| - , m_size(size)
|
| -{
|
| - ScriptWrappable::init(this);
|
| -
|
| - // Create a new internal URL and register it with the same blob data as the source URL.
|
| - m_internalURL = BlobURL::createInternalURL();
|
| - BlobRegistry::registerBlobURL(0, m_internalURL, srcURL);
|
| }
|
|
|
| Blob::~Blob()
|
| {
|
| - BlobRegistry::unregisterBlobURL(m_internalURL);
|
| }
|
|
|
| PassRefPtr<Blob> Blob::slice(long long start, long long end, const String& contentType) const
|
| @@ -113,8 +86,8 @@ PassRefPtr<Blob> Blob::slice(long long start, long long end, const String& conte
|
| // FIXME: This involves synchronous file operation. We need to figure out how to make it asynchronous.
|
| toFile(this)->captureSnapshot(size, modificationTime);
|
| } else {
|
| - ASSERT(m_size != -1);
|
| - size = m_size;
|
| + size = this->size();
|
| + ASSERT(size != -1);
|
| }
|
|
|
| // Convert the negative value that is used to select from the end.
|
| @@ -141,13 +114,13 @@ PassRefPtr<Blob> Blob::slice(long long start, long long end, const String& conte
|
| blobData->setContentType(contentType);
|
| if (isFile()) {
|
| if (!toFile(this)->fileSystemURL().isEmpty())
|
| - blobData->appendURL(toFile(this)->fileSystemURL(), start, length, modificationTime);
|
| + blobData->appendFileSystemURL(toFile(this)->fileSystemURL(), start, length, modificationTime);
|
| else
|
| blobData->appendFile(toFile(this)->path(), start, length, modificationTime);
|
| - } else
|
| - blobData->appendBlob(m_internalURL, start, length);
|
| -
|
| - return Blob::create(blobData.release(), length);
|
| + } else {
|
| + blobData->appendBlob(m_blobDataHandle, start, length);
|
| + }
|
| + return Blob::create(BlobDataHandle::create(blobData.release(), length));
|
| }
|
|
|
| URLRegistry& Blob::registry() const
|
|
|