| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef Blob_h | 31 #ifndef Blob_h |
| 32 #define Blob_h | 32 #define Blob_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptWrappable.h" | 34 #include "bindings/v8/ScriptWrappable.h" |
| 35 #include "core/html/URLRegistry.h" | 35 #include "core/html/URLRegistry.h" |
| 36 #include "heap/Handle.h" |
| 36 #include "platform/blob/BlobData.h" | 37 #include "platform/blob/BlobData.h" |
| 37 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefCounted.h" | 40 #include "wtf/RefCounted.h" |
| 40 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 class ExecutionContext; | 45 class ExecutionContext; |
| 45 | 46 |
| 46 class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Bl
ob> { | 47 class Blob : public RefCountedWillBeGarbageCollectedFinalized<Blob>, public Scri
ptWrappable, public URLRegistrable { |
| 48 DECLARE_GC_INFO; |
| 47 public: | 49 public: |
| 48 static PassRefPtr<Blob> create() | 50 static PassRefPtrWillBeRawPtr<Blob> create() |
| 49 { | 51 { |
| 50 return adoptRef(new Blob(BlobDataHandle::create())); | 52 return adoptRefWillBeNoop(new Blob(BlobDataHandle::create())); |
| 51 } | 53 } |
| 52 | 54 |
| 53 static PassRefPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDataHandle) | 55 static PassRefPtrWillBeRawPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDa
taHandle) |
| 54 { | 56 { |
| 55 return adoptRef(new Blob(blobDataHandle)); | 57 return adoptRefWillBeNoop(new Blob(blobDataHandle)); |
| 56 } | 58 } |
| 57 | 59 |
| 58 virtual ~Blob(); | 60 virtual ~Blob(); |
| 59 | 61 |
| 60 virtual unsigned long long size() const { return m_blobDataHandle->size(); } | 62 virtual unsigned long long size() const { return m_blobDataHandle->size(); } |
| 61 virtual PassRefPtr<Blob> slice(long long start = 0, long long end = std::num
eric_limits<long long>::max(), const String& contentType = String()) const; | 63 virtual PassRefPtrWillBeRawPtr<Blob> slice(long long start = 0, long long en
d = std::numeric_limits<long long>::max(), const String& contentType = String())
const; |
| 62 | 64 |
| 63 String type() const { return m_blobDataHandle->type(); } | 65 String type() const { return m_blobDataHandle->type(); } |
| 64 String uuid() const { return m_blobDataHandle->uuid(); } | 66 String uuid() const { return m_blobDataHandle->uuid(); } |
| 65 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} | 67 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} |
| 66 // True for all File instances, including the user-built ones. | 68 // True for all File instances, including the user-built ones. |
| 67 virtual bool isFile() const { return false; } | 69 virtual bool isFile() const { return false; } |
| 68 // Only true for File instances that are backed by platform files. | 70 // Only true for File instances that are backed by platform files. |
| 69 virtual bool hasBackingFile() const { return false; } | 71 virtual bool hasBackingFile() const { return false; } |
| 70 | 72 |
| 71 // Used by the JavaScript Blob and File constructors. | 73 // Used by the JavaScript Blob and File constructors. |
| 72 virtual void appendTo(BlobData&) const; | 74 virtual void appendTo(BlobData&) const; |
| 73 | 75 |
| 74 // URLRegistrable to support PublicURLs. | 76 // URLRegistrable to support PublicURLs. |
| 75 virtual URLRegistry& registry() const OVERRIDE FINAL; | 77 virtual URLRegistry& registry() const OVERRIDE FINAL; |
| 76 | 78 |
| 77 static void clampSliceOffsets(long long size, long long& start, long long& e
nd); | 79 static void clampSliceOffsets(long long size, long long& start, long long& e
nd); |
| 80 |
| 81 void trace(Visitor*) { } |
| 82 |
| 78 protected: | 83 protected: |
| 79 explicit Blob(PassRefPtr<BlobDataHandle>); | 84 explicit Blob(PassRefPtr<BlobDataHandle>); |
| 80 | 85 |
| 81 private: | 86 private: |
| 82 Blob(); | 87 Blob(); |
| 83 RefPtr<BlobDataHandle> m_blobDataHandle; | 88 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 84 }; | 89 }; |
| 85 | 90 |
| 86 } // namespace WebCore | 91 } // namespace WebCore |
| 87 | 92 |
| 88 #endif // Blob_h | 93 #endif // Blob_h |
| OLD | NEW |