| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/html/URLRegistry.h" | 35 #include "core/html/URLRegistry.h" |
| 36 #include "heap/Handle.h" | 36 #include "heap/Handle.h" |
| 37 #include "platform/blob/BlobData.h" | 37 #include "platform/blob/BlobData.h" |
| 38 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 39 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 40 #include "wtf/RefCounted.h" | 40 #include "wtf/RefCounted.h" |
| 41 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
| 42 | 42 |
| 43 namespace WebCore { | 43 namespace WebCore { |
| 44 | 44 |
| 45 class ExceptionState; |
| 45 class ExecutionContext; | 46 class ExecutionContext; |
| 46 | 47 |
| 47 class Blob : public RefCountedWillBeGarbageCollectedFinalized<Blob>, public Scri
ptWrappable, public URLRegistrable { | 48 class Blob : public RefCountedWillBeGarbageCollectedFinalized<Blob>, public Scri
ptWrappable, public URLRegistrable { |
| 48 public: | 49 public: |
| 49 static PassRefPtrWillBeRawPtr<Blob> create() | 50 static PassRefPtrWillBeRawPtr<Blob> create() |
| 50 { | 51 { |
| 51 return adoptRefWillBeNoop(new Blob(BlobDataHandle::create())); | 52 return adoptRefWillBeNoop(new Blob(BlobDataHandle::create())); |
| 52 } | 53 } |
| 53 | 54 |
| 54 static PassRefPtrWillBeRawPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDa
taHandle) | 55 static PassRefPtrWillBeRawPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDa
taHandle) |
| 55 { | 56 { |
| 56 return adoptRefWillBeNoop(new Blob(blobDataHandle)); | 57 return adoptRefWillBeNoop(new Blob(blobDataHandle)); |
| 57 } | 58 } |
| 58 | 59 |
| 59 virtual ~Blob(); | 60 virtual ~Blob(); |
| 60 | 61 |
| 61 virtual unsigned long long size() const { return m_blobDataHandle->size(); } | 62 virtual unsigned long long size() const { return m_blobDataHandle->size(); } |
| 62 virtual PassRefPtrWillBeRawPtr<Blob> slice(long long start = 0, long long en
d = std::numeric_limits<long long>::max(), const String& contentType = String())
const; | 63 virtual PassRefPtrWillBeRawPtr<Blob> slice(long long start, long long end, c
onst String& contentType, ExceptionState&) const; |
| 63 virtual void close(ExecutionContext*); | 64 |
| 65 // To allow ExceptionState to be passed in last, manually enumerate the opti
onal argument overloads. |
| 66 PassRefPtrWillBeRawPtr<Blob> slice(ExceptionState& exceptionState) const |
| 67 { |
| 68 return slice(0, std::numeric_limits<long long>::max(), String(), excepti
onState); |
| 69 } |
| 70 PassRefPtrWillBeRawPtr<Blob> slice(long long start, ExceptionState& exceptio
nState) const |
| 71 { |
| 72 return slice(start, std::numeric_limits<long long>::max(), String(), exc
eptionState); |
| 73 } |
| 74 PassRefPtrWillBeRawPtr<Blob> slice(long long start, long long end, Exception
State& exceptionState) const |
| 75 { |
| 76 return slice(start, end, String(), exceptionState); |
| 77 } |
| 78 |
| 79 virtual void close(ExecutionContext*, ExceptionState&); |
| 64 | 80 |
| 65 String type() const { return m_blobDataHandle->type(); } | 81 String type() const { return m_blobDataHandle->type(); } |
| 66 String uuid() const { return m_blobDataHandle->uuid(); } | 82 String uuid() const { return m_blobDataHandle->uuid(); } |
| 67 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} | 83 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} |
| 68 // True for all File instances, including the user-built ones. | 84 // True for all File instances, including the user-built ones. |
| 69 virtual bool isFile() const { return false; } | 85 virtual bool isFile() const { return false; } |
| 70 // Only true for File instances that are backed by platform files. | 86 // Only true for File instances that are backed by platform files. |
| 71 virtual bool hasBackingFile() const { return false; } | 87 virtual bool hasBackingFile() const { return false; } |
| 72 bool hasBeenClosed() const { return m_hasBeenClosed; } | 88 bool hasBeenClosed() const { return m_hasBeenClosed; } |
| 73 | 89 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 86 private: | 102 private: |
| 87 Blob(); | 103 Blob(); |
| 88 | 104 |
| 89 RefPtr<BlobDataHandle> m_blobDataHandle; | 105 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 90 bool m_hasBeenClosed; | 106 bool m_hasBeenClosed; |
| 91 }; | 107 }; |
| 92 | 108 |
| 93 } // namespace WebCore | 109 } // namespace WebCore |
| 94 | 110 |
| 95 #endif // Blob_h | 111 #endif // Blob_h |
| OLD | NEW |