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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 ReadAsDataURL, | 62 ReadAsDataURL, |
63 ReadByClient | 63 ReadByClient |
64 }; | 64 }; |
65 | 65 |
66 // If client is given, do the loading asynchronously. Otherwise, load synchr
onously. | 66 // If client is given, do the loading asynchronously. Otherwise, load synchr
onously. |
67 static std::unique_ptr<FileReaderLoader> create(ReadType readType, FileReade
rLoaderClient* client) | 67 static std::unique_ptr<FileReaderLoader> create(ReadType readType, FileReade
rLoaderClient* client) |
68 { | 68 { |
69 return wrapUnique(new FileReaderLoader(readType, client)); | 69 return wrapUnique(new FileReaderLoader(readType, client)); |
70 } | 70 } |
71 | 71 |
72 FileReaderLoader(ReadType, FileReaderLoaderClient*); | |
73 ~FileReaderLoader() override; | 72 ~FileReaderLoader() override; |
74 | 73 |
75 void start(ExecutionContext*, PassRefPtr<BlobDataHandle>); | 74 void start(ExecutionContext*, PassRefPtr<BlobDataHandle>); |
76 void start(ExecutionContext*, const Stream&, unsigned readSize); | 75 void start(ExecutionContext*, const Stream&, unsigned readSize); |
77 void cancel(); | 76 void cancel(); |
78 | 77 |
79 // ThreadableLoaderClient | 78 // ThreadableLoaderClient |
80 void didReceiveResponse(unsigned long, const ResourceResponse&, std::unique_
ptr<WebDataConsumerHandle>) override; | 79 void didReceiveResponse(unsigned long, const ResourceResponse&, std::unique_
ptr<WebDataConsumerHandle>) override; |
81 void didReceiveData(const char*, unsigned) override; | 80 void didReceiveData(const char*, unsigned) override; |
82 void didFinishLoading(unsigned long, double) override; | 81 void didFinishLoading(unsigned long, double) override; |
(...skipping 16 matching lines...) Expand all Loading... |
99 // called), returns it. | 98 // called), returns it. |
100 // - Otherwise, returns -1. | 99 // - Otherwise, returns -1. |
101 long long totalBytes() const { return m_totalBytes; } | 100 long long totalBytes() const { return m_totalBytes; } |
102 | 101 |
103 FileError::ErrorCode errorCode() const { return m_errorCode; } | 102 FileError::ErrorCode errorCode() const { return m_errorCode; } |
104 | 103 |
105 void setEncoding(const String&); | 104 void setEncoding(const String&); |
106 void setDataType(const String& dataType) { m_dataType = dataType; } | 105 void setDataType(const String& dataType) { m_dataType = dataType; } |
107 | 106 |
108 private: | 107 private: |
| 108 FileReaderLoader(ReadType, FileReaderLoaderClient*); |
| 109 |
109 void startInternal(ExecutionContext&, const Stream*, PassRefPtr<BlobDataHand
le>); | 110 void startInternal(ExecutionContext&, const Stream*, PassRefPtr<BlobDataHand
le>); |
110 void cleanup(); | 111 void cleanup(); |
111 | 112 |
112 void failed(FileError::ErrorCode); | 113 void failed(FileError::ErrorCode); |
113 void convertToText(); | 114 void convertToText(); |
114 void convertToDataURL(); | 115 void convertToDataURL(); |
115 | 116 |
116 static FileError::ErrorCode httpStatusCodeToErrorCode(int); | 117 static FileError::ErrorCode httpStatusCodeToErrorCode(int); |
117 | 118 |
118 ReadType m_readType; | 119 ReadType m_readType; |
(...skipping 25 matching lines...) Expand all Loading... |
144 bool m_hasRange; | 145 bool m_hasRange; |
145 unsigned m_rangeStart; | 146 unsigned m_rangeStart; |
146 unsigned m_rangeEnd; | 147 unsigned m_rangeEnd; |
147 | 148 |
148 FileError::ErrorCode m_errorCode; | 149 FileError::ErrorCode m_errorCode; |
149 }; | 150 }; |
150 | 151 |
151 } // namespace blink | 152 } // namespace blink |
152 | 153 |
153 #endif // FileReaderLoader_h | 154 #endif // FileReaderLoader_h |
OLD | NEW |