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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 void FileReaderLoader::start(ExecutionContext* executionContext, const Stream& s
tream, unsigned readSize) | 129 void FileReaderLoader::start(ExecutionContext* executionContext, const Stream& s
tream, unsigned readSize) |
130 { | 130 { |
131 if (readSize > 0) { | 131 if (readSize > 0) { |
132 m_hasRange = true; | 132 m_hasRange = true; |
133 m_rangeStart = 0; | 133 m_rangeStart = 0; |
134 m_rangeEnd = readSize - 1; // End is inclusive so (0,0) is a 1-byte read
. | 134 m_rangeEnd = readSize - 1; // End is inclusive so (0,0) is a 1-byte read
. |
135 } | 135 } |
136 | 136 |
137 m_urlForReadingIsStream = true; | 137 m_urlForReadingIsStream = true; |
138 startInternal(executionContext, &stream, 0); | 138 startInternal(executionContext, &stream, nullptr); |
139 } | 139 } |
140 | 140 |
141 void FileReaderLoader::cancel() | 141 void FileReaderLoader::cancel() |
142 { | 142 { |
143 m_errorCode = FileError::ABORT_ERR; | 143 m_errorCode = FileError::ABORT_ERR; |
144 terminate(); | 144 terminate(); |
145 } | 145 } |
146 | 146 |
147 void FileReaderLoader::terminate() | 147 void FileReaderLoader::terminate() |
148 { | 148 { |
149 if (m_loader) { | 149 if (m_loader) { |
150 m_loader->cancel(); | 150 m_loader->cancel(); |
151 cleanup(); | 151 cleanup(); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 void FileReaderLoader::cleanup() | 155 void FileReaderLoader::cleanup() |
156 { | 156 { |
157 m_loader = 0; | 157 m_loader = nullptr; |
158 | 158 |
159 // If we get any error, we do not need to keep a buffer around. | 159 // If we get any error, we do not need to keep a buffer around. |
160 if (m_errorCode) { | 160 if (m_errorCode) { |
161 m_rawData.clear(); | 161 m_rawData.clear(); |
162 m_stringResult = ""; | 162 m_stringResult = ""; |
163 m_isRawDataConverted = true; | 163 m_isRawDataConverted = true; |
164 m_decoder.clear(); | 164 m_decoder.clear(); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 return FileError::NOT_READABLE_ERR; | 297 return FileError::NOT_READABLE_ERR; |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 PassRefPtr<ArrayBuffer> FileReaderLoader::arrayBufferResult() const | 301 PassRefPtr<ArrayBuffer> FileReaderLoader::arrayBufferResult() const |
302 { | 302 { |
303 ASSERT(m_readType == ReadAsArrayBuffer); | 303 ASSERT(m_readType == ReadAsArrayBuffer); |
304 | 304 |
305 // If the loading is not started or an error occurs, return an empty result. | 305 // If the loading is not started or an error occurs, return an empty result. |
306 if (!m_rawData || m_errorCode) | 306 if (!m_rawData || m_errorCode) |
307 return 0; | 307 return nullptr; |
308 | 308 |
309 return m_rawData->toArrayBuffer(); | 309 return m_rawData->toArrayBuffer(); |
310 } | 310 } |
311 | 311 |
312 String FileReaderLoader::stringResult() | 312 String FileReaderLoader::stringResult() |
313 { | 313 { |
314 ASSERT(m_readType != ReadAsArrayBuffer && m_readType != ReadAsBlob && m_read
Type != ReadByClient); | 314 ASSERT(m_readType != ReadAsArrayBuffer && m_readType != ReadAsBlob && m_read
Type != ReadByClient); |
315 | 315 |
316 // If the loading is not started or an error occurs, return an empty result. | 316 // If the loading is not started or an error occurs, return an empty result. |
317 if (!m_rawData || m_errorCode) | 317 if (!m_rawData || m_errorCode) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 m_stringResult = builder.toString(); | 392 m_stringResult = builder.toString(); |
393 } | 393 } |
394 | 394 |
395 void FileReaderLoader::setEncoding(const String& encoding) | 395 void FileReaderLoader::setEncoding(const String& encoding) |
396 { | 396 { |
397 if (!encoding.isEmpty()) | 397 if (!encoding.isEmpty()) |
398 m_encoding = WTF::TextEncoding(encoding); | 398 m_encoding = WTF::TextEncoding(encoding); |
399 } | 399 } |
400 | 400 |
401 } // namespace WebCore | 401 } // namespace WebCore |
OLD | NEW |