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

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 7 years, 11 months 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
« no previous file with comments | « WebCore/bindings/v8/SerializedScriptValue.cpp ('k') | WebCore/fileapi/Blob.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
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"
35 #include "KURL.h"
36 #include "ScriptWrappable.h" 35 #include "ScriptWrappable.h"
37 #include <wtf/PassOwnPtr.h> 36 #include <wtf/PassOwnPtr.h>
38 #include <wtf/PassRefPtr.h> 37 #include <wtf/PassRefPtr.h>
39 #include <wtf/RefCounted.h> 38 #include <wtf/RefCounted.h>
40 #include <wtf/Vector.h> 39 #include <wtf/Vector.h>
41 #include <wtf/text/WTFString.h> 40 #include <wtf/text/WTFString.h>
42 41
43 namespace WebCore { 42 namespace WebCore {
44 43
45 class ScriptExecutionContext; 44 class ScriptExecutionContext;
46 45
47 class Blob : public ScriptWrappable, public RefCounted<Blob> { 46 class Blob : public ScriptWrappable, public RefCounted<Blob> {
48 public: 47 public:
49 static PassRefPtr<Blob> create() 48 static PassRefPtr<Blob> create()
50 { 49 {
51 return adoptRef(new Blob); 50 return adoptRef(new Blob(BlobDataHandle::create()));
52 } 51 }
53 52
54 static PassRefPtr<Blob> create(PassOwnPtr<BlobData> blobData, long long size ) 53 static PassRefPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDataHandle)
55 { 54 {
56 return adoptRef(new Blob(blobData, size)); 55 return adoptRef(new Blob(blobDataHandle));
57 }
58
59 // For deserialization.
60 static PassRefPtr<Blob> create(const KURL& srcURL, const String& type, long long size)
61 {
62 return adoptRef(new Blob(srcURL, type, size));
63 } 56 }
64 57
65 virtual ~Blob(); 58 virtual ~Blob();
66 59
67 const KURL& url() const { return m_internalURL; } 60 String uuid() const { return m_blobDataHandle->uuid(); }
68 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; }
69 64
70 virtual unsigned long long size() const { return static_cast<unsigned long l ong>(m_size); } 65 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle; }
71 virtual bool isFile() const { return false; }
72 66
73 #if ENABLE(BLOB) 67 #if ENABLE(BLOB)
74 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;
75 #endif 69 #endif
76 70
77 protected: 71 protected:
72 Blob(PassRefPtr<BlobDataHandle>);
73
74 private:
78 Blob(); 75 Blob();
79 Blob(PassOwnPtr<BlobData>, long long size); 76 RefPtr<BlobDataHandle> m_blobDataHandle;
80
81 // For deserialization.
82 Blob(const KURL& srcURL, const String& type, long long size);
83
84 // This is an internal URL referring to the blob data associated with this o bject. It serves
85 // as an identifier for this blob. The internal URL is never used to source the blob's content
86 // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
87 KURL m_internalURL;
88
89 String m_type;
90 long long m_size;
91 }; 77 };
92 78
93 } // namespace WebCore 79 } // namespace WebCore
94 80
95 #endif // Blob_h 81 #endif // Blob_h
OLDNEW
« no previous file with comments | « WebCore/bindings/v8/SerializedScriptValue.cpp ('k') | WebCore/fileapi/Blob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698