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

Side by Side Diff: Source/core/fileapi/Blob.h

Issue 23992003: blob hacking webcore style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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 | « Source/bindings/v8/SerializedScriptValue.cpp ('k') | Source/core/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 16 matching lines...) Expand all
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 "core/platform/network/BlobData.h" 36 #include "core/platform/network/BlobData.h"
37 #include "weborigin/KURL.h"
38 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
39 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
40 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.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 ExecutionContext; 44 class ExecutionContext;
46 45
47 class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Bl ob> { 46 class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Bl ob> {
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; }
64 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle; }
65 PassRefPtr<Blob> slice(long long start = 0, long long end = std::numeric_lim its<long long>::max(), const String& contentType = String()) const;
69 66
70 virtual unsigned long long size() const { return static_cast<unsigned long l ong>(m_size); } 67 // URLRegistrable to support PublicURLs.
71 virtual bool isFile() const { return false; }
72
73 // URLRegistrable
74 virtual URLRegistry& registry() const OVERRIDE; 68 virtual URLRegistry& registry() const OVERRIDE;
75 69
76 PassRefPtr<Blob> slice(long long start = 0, long long end = std::numeric_lim its<long long>::max(), const String& contentType = String()) const; 70 protected:
71 explicit Blob(PassRefPtr<BlobDataHandle>);
77 72
78 protected: 73 private:
79 Blob(); 74 Blob();
80 Blob(PassOwnPtr<BlobData>, long long size); 75 RefPtr<BlobDataHandle> m_blobDataHandle;
81
82 // For deserialization.
83 Blob(const KURL& srcURL, const String& type, long long size);
84
85 // This is an internal URL referring to the blob data associated with this o bject. It serves
86 // as an identifier for this blob. The internal URL is never used to source the blob's content
87 // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
88 KURL m_internalURL;
89
90 String m_type;
91 long long m_size;
92 }; 76 };
93 77
94 } // namespace WebCore 78 } // namespace WebCore
95 79
96 #endif // Blob_h 80 #endif // Blob_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/SerializedScriptValue.cpp ('k') | Source/core/fileapi/Blob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698