| 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 13 matching lines...) Expand all Loading... |
| 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 "ExceptionCode.h" | 34 #include "BlobItem.h" |
| 35 #include "PlatformString.h" | 35 #include "PlatformString.h" |
| 36 #include <time.h> | |
| 37 #include <wtf/PassRefPtr.h> | 36 #include <wtf/PassRefPtr.h> |
| 38 #include <wtf/RefCounted.h> | 37 #include <wtf/RefCounted.h> |
| 38 #include <wtf/Vector.h> |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 class Blob : public RefCounted<Blob> { | 42 class Blob : public RefCounted<Blob> { |
| 43 public: | 43 public: |
| 44 #if ENABLE(BLOB_SLICE) | 44 static PassRefPtr<Blob> create() |
| 45 static const int toEndOfFile; | 45 { |
| 46 static const double doNotCheckFileChange; | 46 return adoptRef(new Blob()); |
| 47 #endif | 47 } |
| 48 | 48 |
| 49 // FIXME: Deprecated method. This is called only from |
| 50 // bindings/v8/SerializedScriptValue.cpp and the usage in it will become inv
alid once |
| 51 // BlobBuilder is introduced. |
| 49 static PassRefPtr<Blob> create(const String& path) | 52 static PassRefPtr<Blob> create(const String& path) |
| 50 { | 53 { |
| 51 return adoptRef(new Blob(path)); | 54 return adoptRef(new Blob(path)); |
| 52 } | 55 } |
| 53 | 56 |
| 54 virtual ~Blob() { } | 57 virtual ~Blob() { } |
| 55 | 58 |
| 59 unsigned long long size() const; |
| 60 const String& type() const { return m_type; } |
| 56 virtual bool isFile() const { return false; } | 61 virtual bool isFile() const { return false; } |
| 57 | 62 |
| 63 // FIXME: Deprecated method. |
| 64 const String& path() const; |
| 65 |
| 66 void append(PassRefPtr<BlobItem>); |
| 67 const BlobItemList& items() const { return m_items; } |
| 68 |
| 58 #if ENABLE(BLOB_SLICE) | 69 #if ENABLE(BLOB_SLICE) |
| 59 PassRefPtr<Blob> slice(long long start, long long length) const; | 70 PassRefPtr<Blob> slice(long long start, long long length) const; |
| 60 #endif | 71 #endif |
| 61 | 72 |
| 62 const String& path() const { return m_path; } | 73 protected: |
| 63 unsigned long long size() const; | 74 Blob() { } |
| 64 #if ENABLE(BLOB_SLICE) | |
| 65 long long start() const { return m_start; } | |
| 66 long long length() const { return m_length; } | |
| 67 double modificationTime() const { return m_snapshotModificationTime; } | |
| 68 #endif | |
| 69 | 75 |
| 70 protected: | 76 // FIXME: Deprecated constructor. See also the comment for Blob::create(pat
h). |
| 71 Blob(const String& path); | 77 Blob(const String& path); |
| 72 | 78 |
| 73 private: | 79 BlobItemList m_items; |
| 74 #if ENABLE(BLOB_SLICE) | 80 String m_type; |
| 75 Blob(const String& path, long long start, long long length, long long snapsh
otSize, double snapshotModificationTime); | |
| 76 #endif | |
| 77 | |
| 78 // The underlying path of the file-based blob. | |
| 79 String m_path; | |
| 80 | |
| 81 #if ENABLE(BLOB_SLICE) | |
| 82 // The starting position of the file-based blob. | |
| 83 long long m_start; | |
| 84 | |
| 85 // The length of the file-based blob. The value of -1 means to the end of th
e file. | |
| 86 long long m_length; | |
| 87 | |
| 88 // A flag to tell if a snapshot has been captured. | |
| 89 bool m_snapshotCaptured; | |
| 90 | |
| 91 // The size of the file when a snapshot is captured. It can be 0 if the file
is empty. | |
| 92 long long m_snapshotSize; | |
| 93 | |
| 94 // The last modification time of the file when a snapshot is captured. The v
alue of 0 also means that the snapshot is not captured. | |
| 95 double m_snapshotModificationTime; | |
| 96 #endif | |
| 97 }; | 81 }; |
| 98 | 82 |
| 99 } // namespace WebCore | 83 } // namespace WebCore |
| 100 | 84 |
| 101 #endif // Blob_h | 85 #endif // Blob_h |
| OLD | NEW |