diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/fileapi/Blob.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/fileapi/Blob.h')
-rw-r--r-- | Source/WebCore/fileapi/Blob.h | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/Source/WebCore/fileapi/Blob.h b/Source/WebCore/fileapi/Blob.h index 3e1e2ad9f..e7b6f8e8f 100644 --- a/Source/WebCore/fileapi/Blob.h +++ b/Source/WebCore/fileapi/Blob.h @@ -28,38 +28,47 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef Blob_h -#define Blob_h +#pragma once -#include "BlobData.h" -#include "URL.h" +#include "BlobPropertyBag.h" #include "ScriptWrappable.h" +#include "URL.h" #include "URLRegistry.h" -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/text/WTFString.h> +#include <wtf/Variant.h> + +namespace JSC { +class ArrayBufferView; +class ArrayBuffer; +} namespace WebCore { +class Blob; class ScriptExecutionContext; +using BlobPartVariant = Variant<RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayBuffer>, RefPtr<Blob>, String>; + class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Blob> { public: - static PassRefPtr<Blob> create() + static Ref<Blob> create() { - return adoptRef(new Blob); + return adoptRef(*new Blob); } - static PassRefPtr<Blob> create(std::unique_ptr<BlobData> blobData, long long size) + static Ref<Blob> create(Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag) { - return adoptRef(new Blob(std::move(blobData), size)); + return adoptRef(*new Blob(WTFMove(blobPartVariants), propertyBag)); } - // For deserialization. - static PassRefPtr<Blob> create(const URL& srcURL, const String& type, long long size) + static Ref<Blob> create(Vector<uint8_t>&& data, const String& contentType) + { + return adoptRef(*new Blob(WTFMove(data), contentType)); + } + + static Ref<Blob> deserialize(const URL& srcURL, const String& type, long long size, const String& fileBackedPath) { ASSERT(Blob::isNormalizedContentType(type)); - return adoptRef(new Blob(srcURL, type, size)); + return adoptRef(*new Blob(deserializationContructor, srcURL, type, size, fileBackedPath)); } virtual ~Blob(); @@ -67,30 +76,39 @@ public: const URL& url() const { return m_internalURL; } const String& type() const { return m_type; } - virtual unsigned long long size() const { return static_cast<unsigned long long>(m_size); } + WEBCORE_EXPORT unsigned long long size() const; virtual bool isFile() const { return false; } // The checks described in the File API spec. static bool isValidContentType(const String&); // The normalization procedure described in the File API spec. static String normalizedContentType(const String&); - // Intended for use in ASSERT statements. +#if !ASSERT_DISABLED static bool isNormalizedContentType(const String&); static bool isNormalizedContentType(const CString&); +#endif // URLRegistrable - virtual URLRegistry& registry() const override; + URLRegistry& registry() const override; -#if ENABLE(BLOB) - PassRefPtr<Blob> slice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const; -#endif + Ref<Blob> slice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const + { + return adoptRef(*new Blob(m_internalURL, start, end, contentType)); + } protected: Blob(); - Blob(std::unique_ptr<BlobData>, long long size); + Blob(Vector<BlobPartVariant>&&, const BlobPropertyBag&); + Blob(Vector<uint8_t>&&, const String& contentType); + + enum UninitializedContructor { uninitializedContructor }; + Blob(UninitializedContructor); - // For deserialization. - Blob(const URL& srcURL, const String& type, long long size); + enum DeserializationContructor { deserializationContructor }; + Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size, const String& fileBackedPath); + + // For slicing. + Blob(const URL& srcURL, long long start, long long end, const String& contentType); // This is an internal URL referring to the blob data associated with this object. It serves // as an identifier for this blob. The internal URL is never used to source the blob's content @@ -98,10 +116,7 @@ protected: URL m_internalURL; String m_type; - long long m_size; + mutable long long m_size; }; } // namespace WebCore - -#endif // Blob_h - |