Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: WebCore/fileapi/Blob.h

Issue 11192017: ********** WebCore blob hacking (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 "BlobData.h" 34 #include "BlobData.h" // not needed?
35 #include "KURL.h" 35 #include "KURL.h" // not needed?
36 #include <wtf/PassOwnPtr.h> 36 #include <wtf/PassOwnPtr.h>
37 #include <wtf/PassRefPtr.h> 37 #include <wtf/PassRefPtr.h>
38 #include <wtf/RefCounted.h> 38 #include <wtf/RefCounted.h>
39 #include <wtf/Vector.h> 39 #include <wtf/Vector.h>
40 #include <wtf/text/WTFString.h> 40 #include <wtf/text/WTFString.h>
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 class ScriptExecutionContext; 44 class ScriptExecutionContext;
45 45
46 class Blob : public RefCounted<Blob> { 46 class Blob : public RefCounted<Blob> {
47 public: 47 public:
48 static PassRefPtr<Blob> create() 48 static PassRefPtr<Blob> create()
49 { 49 {
50 return adoptRef(new Blob); 50 return adoptRef(new Blob(BlobDataHandle::create()));
51 } 51 }
52 52
53 static PassRefPtr<Blob> create(PassOwnPtr<BlobData> blobData, long long size ) 53 static PassRefPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDataHandle)
54 { 54 {
55 return adoptRef(new Blob(blobData, size)); 55 return adoptRef(new Blob(blobDataHandle));
56 }
57
58 // For deserialization.
59 static PassRefPtr<Blob> create(const KURL& srcURL, const String& type, long long size)
60 {
61 return adoptRef(new Blob(srcURL, type, size));
62 } 56 }
63 57
64 virtual ~Blob(); 58 virtual ~Blob();
65 59
66 const KURL& url() const { return m_internalURL; } 60 String uuid() const { return m_blobDataHandle->uuid(); }
67 const String& type() const { return m_type; } 61 String type() const { return m_blobDataHandle->type(); }
62 virtual unsigned long long size() const { return m_blobDataHandle->size(); }
63 virtual bool isFile() const { return false; }
68 64
69 virtual unsigned long long size() const { return static_cast<unsigned long l ong>(m_size); } 65 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle; }
70 virtual bool isFile() const { return false; }
71 66
72 #if ENABLE(BLOB) 67 #if ENABLE(BLOB)
73 PassRefPtr<Blob> slice(long long start = 0, long long end = std::numeric_lim its<long long>::max(), const String& contentType = String()) const; 68 PassRefPtr<Blob> slice(long long start = 0, long long end = std::numeric_lim its<long long>::max(), const String& contentType = String()) const;
74 #endif 69 #endif
75 70
76 protected: 71 protected:
72 Blob(PassRefPtr<BlobDataHandle>);
73
74 private:
77 Blob(); 75 Blob();
78 Blob(PassOwnPtr<BlobData>, long long size); 76 RefPtr<BlobDataHandle> m_blobDataHandle;
79
80 // For deserialization.
81 Blob(const KURL& srcURL, const String& type, long long size);
82
83 // This is an internal URL referring to the blob data associated with this o bject. It serves
84 // as an identifier for this blob. The internal URL is never used to source the blob's content
85 // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
86 KURL m_internalURL;
87
88 String m_type;
89 long long m_size;
90 }; 77 };
91 78
92 } // namespace WebCore 79 } // namespace WebCore
93 80
94 #endif // Blob_h 81 #endif // Blob_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698