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 { |
47 public: | 48 public: |
48 static PassRefPtr<Blob> create() | 49 static PassRefPtrWillBeRawPtr<Blob> create() |
49 { | 50 { |
50 return adoptRef(new Blob(BlobDataHandle::create())); | 51 return adoptRefWillBeNoop(new Blob(BlobDataHandle::create())); |
51 } | 52 } |
52 | 53 |
53 static PassRefPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDataHandle) | 54 static PassRefPtrWillBeRawPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDa
taHandle) |
54 { | 55 { |
55 return adoptRef(new Blob(blobDataHandle)); | 56 return adoptRefWillBeNoop(new Blob(blobDataHandle)); |
56 } | 57 } |
57 | 58 |
58 virtual ~Blob(); | 59 virtual ~Blob(); |
59 | 60 |
60 virtual unsigned long long size() const { return m_blobDataHandle->size(); } | 61 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; | 62 virtual PassRefPtrWillBeRawPtr<Blob> slice(long long start = 0, long long en
d = std::numeric_limits<long long>::max(), const String& contentType = String())
const; |
62 virtual void close(ExecutionContext*); | 63 virtual void close(ExecutionContext*); |
63 | 64 |
64 String type() const { return m_blobDataHandle->type(); } | 65 String type() const { return m_blobDataHandle->type(); } |
65 String uuid() const { return m_blobDataHandle->uuid(); } | 66 String uuid() const { return m_blobDataHandle->uuid(); } |
66 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} | 67 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} |
67 // True for all File instances, including the user-built ones. | 68 // True for all File instances, including the user-built ones. |
68 virtual bool isFile() const { return false; } | 69 virtual bool isFile() const { return false; } |
69 // Only true for File instances that are backed by platform files. | 70 // Only true for File instances that are backed by platform files. |
70 virtual bool hasBackingFile() const { return false; } | 71 virtual bool hasBackingFile() const { return false; } |
71 bool hasBeenClosed() const { return m_hasBeenClosed; } | 72 bool hasBeenClosed() const { return m_hasBeenClosed; } |
72 | 73 |
73 // Used by the JavaScript Blob and File constructors. | 74 // Used by the JavaScript Blob and File constructors. |
74 virtual void appendTo(BlobData&) const; | 75 virtual void appendTo(BlobData&) const; |
75 | 76 |
76 // URLRegistrable to support PublicURLs. | 77 // URLRegistrable to support PublicURLs. |
77 virtual URLRegistry& registry() const OVERRIDE FINAL; | 78 virtual URLRegistry& registry() const OVERRIDE FINAL; |
78 | 79 |
| 80 void trace(Visitor*) { } |
| 81 |
79 protected: | 82 protected: |
80 explicit Blob(PassRefPtr<BlobDataHandle>); | 83 explicit Blob(PassRefPtr<BlobDataHandle>); |
81 | 84 |
82 static void clampSliceOffsets(long long size, long long& start, long long& e
nd); | 85 static void clampSliceOffsets(long long size, long long& start, long long& e
nd); |
83 private: | 86 private: |
84 Blob(); | 87 Blob(); |
85 | 88 |
86 RefPtr<BlobDataHandle> m_blobDataHandle; | 89 RefPtr<BlobDataHandle> m_blobDataHandle; |
87 bool m_hasBeenClosed; | 90 bool m_hasBeenClosed; |
88 }; | 91 }; |
89 | 92 |
90 } // namespace WebCore | 93 } // namespace WebCore |
91 | 94 |
92 #endif // Blob_h | 95 #endif // Blob_h |
OLD | NEW |