Chromium Code Reviews| Index: Source/core/fileapi/Blob.cpp |
| diff --git a/Source/core/fileapi/Blob.cpp b/Source/core/fileapi/Blob.cpp |
| index f93b428a80231f56d3aabcb259fea3a26356e20c..f41badfa479448757531da28f9aa322830f23db3 100644 |
| --- a/Source/core/fileapi/Blob.cpp |
| +++ b/Source/core/fileapi/Blob.cpp |
| @@ -37,7 +37,9 @@ |
| namespace WebCore { |
| -class BlobURLRegistry : public URLRegistry { |
| +namespace { |
| + |
| +class PublicBlobURLRegistry : public URLRegistry { |
|
kinuko
2013/09/30 11:31:53
nit: Now all BlobURLs are public (and this class i
michaeln
2013/09/30 20:50:24
I guess we don't need to. Maybe this was overzealo
|
| public: |
| virtual void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*) OVERRIDE; |
| virtual void unregisterURL(const KURL&) OVERRIDE; |
| @@ -45,62 +47,33 @@ public: |
| static URLRegistry& registry(); |
| }; |
| - |
| -void BlobURLRegistry::registerURL(SecurityOrigin* origin, const KURL& publicURL, URLRegistrable* blob) |
| +void PublicBlobURLRegistry::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 PublicBlobURLRegistry::unregisterURL(const KURL& publicURL) |
| { |
| - BlobRegistry::unregisterBlobURL(url); |
| + BlobRegistry::revokePublicBlobURL(publicURL); |
| } |
| -URLRegistry& BlobURLRegistry::registry() |
| +URLRegistry& PublicBlobURLRegistry::registry() |
| { |
| - DEFINE_STATIC_LOCAL(BlobURLRegistry, instance, ()); |
| + DEFINE_STATIC_LOCAL(PublicBlobURLRegistry, instance, ()); |
| 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,18 +114,18 @@ 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 |
| { |
| - return BlobURLRegistry::registry(); |
| + return PublicBlobURLRegistry::registry(); |
| } |