Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 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 "platform/blob/BlobData.h" | 36 #include "platform/blob/BlobData.h" |
| 37 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.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 ExceptionState; | |
| 44 class ExecutionContext; | 45 class ExecutionContext; |
| 45 | 46 |
| 46 class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Bl ob> { | 47 class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Bl ob> { |
| 47 public: | 48 public: |
| 48 static PassRefPtr<Blob> create() | 49 static PassRefPtr<Blob> create() |
| 49 { | 50 { |
| 50 return adoptRef(new Blob(BlobDataHandle::create())); | 51 return adoptRef(new Blob(BlobDataHandle::create())); |
| 51 } | 52 } |
| 52 | 53 |
| 53 static PassRefPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDataHandle) | 54 static PassRefPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDataHandle) |
| 54 { | 55 { |
| 55 return adoptRef(new Blob(blobDataHandle)); | 56 return adoptRef(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 PassRefPtr<Blob> slice(long long start, long long end, const String& contentType, ExceptionState&) const; |
| 62 virtual void close(ExecutionContext*); | 63 |
| 64 // To allow ExceptionState to be passed in last, manually enumerate the opti onal argument overloads. | |
| 65 PassRefPtr<Blob> slice(ExceptionState& exceptionState) const | |
| 66 { | |
| 67 return slice(0, std::numeric_limits<long long>::max(), String(), excepti onState); | |
| 68 } | |
| 69 PassRefPtr<Blob> slice(long long start, ExceptionState& exceptionState) cons t | |
| 70 { | |
| 71 return slice(start, std::numeric_limits<long long>::max(), String(), exc eptionState); | |
| 72 } | |
| 73 PassRefPtr<Blob> slice(long long start, long long end, ExceptionState& excep tionState) const | |
| 74 { | |
| 75 return slice(start, end, String(), exceptionState); | |
| 76 } | |
|
kinuko
2014/03/03 05:18:46
Oops... sad, is this the common way for adding exc
sof
2014/03/03 09:36:52
It is definitely sad; I don't see a way to express
Nils Barth (inactive)
2014/03/04 01:11:54
No, I don't believe there's currently a cleaner wa
sof
2014/03/04 08:52:56
Having default value support would be the way to g
| |
| 77 | |
| 78 virtual void close(ExecutionContext*, ExceptionState&); | |
| 63 | 79 |
| 64 String type() const { return m_blobDataHandle->type(); } | 80 String type() const { return m_blobDataHandle->type(); } |
| 65 String uuid() const { return m_blobDataHandle->uuid(); } | 81 String uuid() const { return m_blobDataHandle->uuid(); } |
| 66 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle; } | 82 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle; } |
| 67 // True for all File instances, including the user-built ones. | 83 // True for all File instances, including the user-built ones. |
| 68 virtual bool isFile() const { return false; } | 84 virtual bool isFile() const { return false; } |
| 69 // Only true for File instances that are backed by platform files. | 85 // Only true for File instances that are backed by platform files. |
| 70 virtual bool hasBackingFile() const { return false; } | 86 virtual bool hasBackingFile() const { return false; } |
| 71 bool hasBeenClosed() const { return m_hasBeenClosed; } | 87 bool hasBeenClosed() const { return m_hasBeenClosed; } |
| 72 | 88 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 83 private: | 99 private: |
| 84 Blob(); | 100 Blob(); |
| 85 | 101 |
| 86 RefPtr<BlobDataHandle> m_blobDataHandle; | 102 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 87 bool m_hasBeenClosed; | 103 bool m_hasBeenClosed; |
| 88 }; | 104 }; |
| 89 | 105 |
| 90 } // namespace WebCore | 106 } // namespace WebCore |
| 91 | 107 |
| 92 #endif // Blob_h | 108 #endif // Blob_h |
| OLD | NEW |