| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "platform/blob/BlobURL.h" | 43 #include "platform/blob/BlobURL.h" |
| 44 #include "platform/network/ResourceRequest.h" | 44 #include "platform/network/ResourceRequest.h" |
| 45 #include "platform/network/ResourceResponse.h" | 45 #include "platform/network/ResourceResponse.h" |
| 46 #include "wtf/PassOwnPtr.h" | 46 #include "wtf/PassOwnPtr.h" |
| 47 #include "wtf/PassRefPtr.h" | 47 #include "wtf/PassRefPtr.h" |
| 48 #include "wtf/RefPtr.h" | 48 #include "wtf/RefPtr.h" |
| 49 #include "wtf/Vector.h" | 49 #include "wtf/Vector.h" |
| 50 #include "wtf/text/Base64.h" | 50 #include "wtf/text/Base64.h" |
| 51 #include "wtf/text/StringBuilder.h" | 51 #include "wtf/text/StringBuilder.h" |
| 52 | 52 |
| 53 using namespace std; |
| 54 |
| 53 namespace WebCore { | 55 namespace WebCore { |
| 54 | 56 |
| 55 FileReaderLoader::FileReaderLoader(ReadType readType, FileReaderLoaderClient* cl
ient) | 57 FileReaderLoader::FileReaderLoader(ReadType readType, FileReaderLoaderClient* cl
ient) |
| 56 : m_readType(readType) | 58 : m_readType(readType) |
| 57 , m_client(client) | 59 , m_client(client) |
| 58 , m_urlForReadingIsStream(false) | 60 , m_urlForReadingIsStream(false) |
| 59 , m_isRawDataConverted(false) | 61 , m_isRawDataConverted(false) |
| 60 , m_stringResult("") | 62 , m_stringResult("") |
| 61 , m_finishedLoading(false) | 63 , m_finishedLoading(false) |
| 62 , m_bytesLoaded(0) | 64 , m_bytesLoaded(0) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // default size. | 192 // default size. |
| 191 m_totalBytes = -1; | 193 m_totalBytes = -1; |
| 192 } | 194 } |
| 193 | 195 |
| 194 ASSERT(!m_rawData); | 196 ASSERT(!m_rawData); |
| 195 | 197 |
| 196 if (m_readType != ReadByClient) { | 198 if (m_readType != ReadByClient) { |
| 197 // Check that we can cast to unsigned since we have to do | 199 // Check that we can cast to unsigned since we have to do |
| 198 // so to call ArrayBuffer's create function. | 200 // so to call ArrayBuffer's create function. |
| 199 // FIXME: Support reading more than the current size limit of ArrayBuffe
r. | 201 // FIXME: Support reading more than the current size limit of ArrayBuffe
r. |
| 200 if (initialBufferLength > std::numeric_limits<unsigned>::max()) { | 202 if (initialBufferLength > numeric_limits<unsigned>::max()) { |
| 201 failed(FileError::NOT_READABLE_ERR); | 203 failed(FileError::NOT_READABLE_ERR); |
| 202 return; | 204 return; |
| 203 } | 205 } |
| 204 | 206 |
| 205 if (initialBufferLength < 0) | 207 if (initialBufferLength < 0) |
| 206 m_rawData = adoptPtr(new ArrayBufferBuilder()); | 208 m_rawData = adoptPtr(new ArrayBufferBuilder()); |
| 207 else | 209 else |
| 208 m_rawData = adoptPtr(new ArrayBufferBuilder(static_cast<unsigned>(in
itialBufferLength))); | 210 m_rawData = adoptPtr(new ArrayBufferBuilder(static_cast<unsigned>(in
itialBufferLength))); |
| 209 | 211 |
| 210 if (!m_rawData || !m_rawData->isValid()) { | 212 if (!m_rawData || !m_rawData->isValid()) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 m_stringResult = builder.toString(); | 397 m_stringResult = builder.toString(); |
| 396 } | 398 } |
| 397 | 399 |
| 398 void FileReaderLoader::setEncoding(const String& encoding) | 400 void FileReaderLoader::setEncoding(const String& encoding) |
| 399 { | 401 { |
| 400 if (!encoding.isEmpty()) | 402 if (!encoding.isEmpty()) |
| 401 m_encoding = WTF::TextEncoding(encoding); | 403 m_encoding = WTF::TextEncoding(encoding); |
| 402 } | 404 } |
| 403 | 405 |
| 404 } // namespace WebCore | 406 } // namespace WebCore |
| OLD | NEW |