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 16 matching lines...) Expand all Loading... |
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 FileReaderLoader_h | 31 #ifndef FileReaderLoader_h |
32 #define FileReaderLoader_h | 32 #define FileReaderLoader_h |
33 | 33 |
34 #include "core/fileapi/FileError.h" | 34 #include "core/fileapi/FileError.h" |
35 #include "core/loader/ThreadableLoaderClient.h" | 35 #include "core/loader/ThreadableLoaderClient.h" |
36 #include "platform/weborigin/KURL.h" | 36 #include "platform/weborigin/KURL.h" |
37 #include "wtf/ArrayBuffer.h" | |
38 #include "wtf/ArrayBufferBuilder.h" | 37 #include "wtf/ArrayBufferBuilder.h" |
39 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
40 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
41 #include "wtf/text/TextEncoding.h" | 40 #include "wtf/text/TextEncoding.h" |
42 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
43 | 42 |
44 namespace blink { | 43 namespace blink { |
45 | 44 |
46 class BlobDataHandle; | 45 class BlobDataHandle; |
| 46 class DOMArrayBuffer; |
| 47 class ExecutionContext; |
47 class FileReaderLoaderClient; | 48 class FileReaderLoaderClient; |
48 class ExecutionContext; | |
49 class Stream; | 49 class Stream; |
50 class TextResourceDecoder; | 50 class TextResourceDecoder; |
51 class ThreadableLoader; | 51 class ThreadableLoader; |
52 | 52 |
53 class FileReaderLoader final : public ThreadableLoaderClient { | 53 class FileReaderLoader final : public ThreadableLoaderClient { |
54 public: | 54 public: |
55 enum ReadType { | 55 enum ReadType { |
56 ReadAsArrayBuffer, | 56 ReadAsArrayBuffer, |
57 ReadAsBinaryString, | 57 ReadAsBinaryString, |
58 ReadAsBlob, | 58 ReadAsBlob, |
(...skipping 10 matching lines...) Expand all Loading... |
69 void start(ExecutionContext*, const Stream&, unsigned readSize); | 69 void start(ExecutionContext*, const Stream&, unsigned readSize); |
70 void cancel(); | 70 void cancel(); |
71 | 71 |
72 // ThreadableLoaderClient | 72 // ThreadableLoaderClient |
73 virtual void didReceiveResponse(unsigned long, const ResourceResponse&, Pass
OwnPtr<WebDataConsumerHandle>) override; | 73 virtual void didReceiveResponse(unsigned long, const ResourceResponse&, Pass
OwnPtr<WebDataConsumerHandle>) override; |
74 virtual void didReceiveData(const char*, unsigned) override; | 74 virtual void didReceiveData(const char*, unsigned) override; |
75 virtual void didFinishLoading(unsigned long, double) override; | 75 virtual void didFinishLoading(unsigned long, double) override; |
76 virtual void didFail(const ResourceError&) override; | 76 virtual void didFail(const ResourceError&) override; |
77 | 77 |
78 String stringResult(); | 78 String stringResult(); |
79 PassRefPtr<ArrayBuffer> arrayBufferResult() const; | 79 PassRefPtr<DOMArrayBuffer> arrayBufferResult() const; |
80 | 80 |
81 // Returns the total bytes received. Bytes ignored by m_rawData won't be | 81 // Returns the total bytes received. Bytes ignored by m_rawData won't be |
82 // counted. | 82 // counted. |
83 // | 83 // |
84 // This value doesn't grow more than numeric_limits<unsigned> when | 84 // This value doesn't grow more than numeric_limits<unsigned> when |
85 // m_readType is not set to ReadByClient. | 85 // m_readType is not set to ReadByClient. |
86 long long bytesLoaded() const { return m_bytesLoaded; } | 86 long long bytesLoaded() const { return m_bytesLoaded; } |
87 | 87 |
88 // Before didReceiveResponse() is called: Returns -1. | 88 // Before didReceiveResponse() is called: Returns -1. |
89 // After didReceiveResponse() is called: | 89 // After didReceiveResponse() is called: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 bool m_hasRange; | 138 bool m_hasRange; |
139 unsigned m_rangeStart; | 139 unsigned m_rangeStart; |
140 unsigned m_rangeEnd; | 140 unsigned m_rangeEnd; |
141 | 141 |
142 FileError::ErrorCode m_errorCode; | 142 FileError::ErrorCode m_errorCode; |
143 }; | 143 }; |
144 | 144 |
145 } // namespace blink | 145 } // namespace blink |
146 | 146 |
147 #endif // FileReaderLoader_h | 147 #endif // FileReaderLoader_h |
OLD | NEW |