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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 if (m_readType != ReadByClient) { | 195 if (m_readType != ReadByClient) { |
196 // Check that we can cast to unsigned since we have to do | 196 // Check that we can cast to unsigned since we have to do |
197 // so to call ArrayBuffer's create function. | 197 // so to call ArrayBuffer's create function. |
198 // FIXME: Support reading more than the current size limit of ArrayBuffe
r. | 198 // FIXME: Support reading more than the current size limit of ArrayBuffe
r. |
199 if (initialBufferLength > numeric_limits<unsigned>::max()) { | 199 if (initialBufferLength > numeric_limits<unsigned>::max()) { |
200 failed(FileError::NOT_READABLE_ERR); | 200 failed(FileError::NOT_READABLE_ERR); |
201 return; | 201 return; |
202 } | 202 } |
203 | 203 |
204 if (initialBufferLength < 0) { | 204 if (initialBufferLength < 0) |
205 m_rawData = adoptPtr(new ArrayBufferBuilder()); | 205 m_rawData = adoptPtr(new ArrayBufferBuilder()); |
206 } else { | 206 else |
207 m_rawData = adoptPtr(new ArrayBufferBuilder(static_cast<unsigned>(in
itialBufferLength))); | 207 m_rawData = adoptPtr(new ArrayBufferBuilder(static_cast<unsigned>(in
itialBufferLength))); |
| 208 |
| 209 if (!m_rawData || !m_rawData->isValid()) { |
| 210 failed(FileError::NOT_READABLE_ERR); |
| 211 return; |
| 212 } |
| 213 |
| 214 if (initialBufferLength >= 0) { |
208 // Total size is known. Set m_rawData to ignore overflowed data. | 215 // Total size is known. Set m_rawData to ignore overflowed data. |
209 m_rawData->setVariableCapacity(false); | 216 m_rawData->setVariableCapacity(false); |
210 } | 217 } |
211 | |
212 if (!m_rawData) { | |
213 failed(FileError::NOT_READABLE_ERR); | |
214 return; | |
215 } | |
216 } | 218 } |
217 | 219 |
218 if (m_client) | 220 if (m_client) |
219 m_client->didStartLoading(); | 221 m_client->didStartLoading(); |
220 } | 222 } |
221 | 223 |
222 void FileReaderLoader::didReceiveData(const char* data, int dataLength) | 224 void FileReaderLoader::didReceiveData(const char* data, int dataLength) |
223 { | 225 { |
224 ASSERT(data); | 226 ASSERT(data); |
225 ASSERT(dataLength > 0); | 227 ASSERT(dataLength > 0); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 m_stringResult = builder.toString(); | 394 m_stringResult = builder.toString(); |
393 } | 395 } |
394 | 396 |
395 void FileReaderLoader::setEncoding(const String& encoding) | 397 void FileReaderLoader::setEncoding(const String& encoding) |
396 { | 398 { |
397 if (!encoding.isEmpty()) | 399 if (!encoding.isEmpty()) |
398 m_encoding = WTF::TextEncoding(encoding); | 400 m_encoding = WTF::TextEncoding(encoding); |
399 } | 401 } |
400 | 402 |
401 } // namespace WebCore | 403 } // namespace WebCore |
OLD | NEW |