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