| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const AtomicString& FileReader::interfaceName() const | 87 const AtomicString& FileReader::interfaceName() const |
| 88 { | 88 { |
| 89 return EventTargetNames::FileReader; | 89 return EventTargetNames::FileReader; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void FileReader::stop() | 92 void FileReader::stop() |
| 93 { | 93 { |
| 94 terminate(); | 94 terminate(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void FileReader::readAsArrayBuffer(Blob* blob, ExceptionState& es) | 97 void FileReader::readAsArrayBuffer(Blob* blob, ExceptionState& exceptionState) |
| 98 { | 98 { |
| 99 if (!blob) | 99 if (!blob) |
| 100 return; | 100 return; |
| 101 | 101 |
| 102 LOG(FileAPI, "FileReader: reading as array buffer: %s %s\n", utf8BlobUUID(bl
ob).data(), utf8FilePath(blob).data()); | 102 LOG(FileAPI, "FileReader: reading as array buffer: %s %s\n", utf8BlobUUID(bl
ob).data(), utf8FilePath(blob).data()); |
| 103 | 103 |
| 104 readInternal(blob, FileReaderLoader::ReadAsArrayBuffer, es); | 104 readInternal(blob, FileReaderLoader::ReadAsArrayBuffer, exceptionState); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void FileReader::readAsBinaryString(Blob* blob, ExceptionState& es) | 107 void FileReader::readAsBinaryString(Blob* blob, ExceptionState& exceptionState) |
| 108 { | 108 { |
| 109 if (!blob) | 109 if (!blob) |
| 110 return; | 110 return; |
| 111 | 111 |
| 112 LOG(FileAPI, "FileReader: reading as binary: %s %s\n", utf8BlobUUID(blob).da
ta(), utf8FilePath(blob).data()); | 112 LOG(FileAPI, "FileReader: reading as binary: %s %s\n", utf8BlobUUID(blob).da
ta(), utf8FilePath(blob).data()); |
| 113 | 113 |
| 114 readInternal(blob, FileReaderLoader::ReadAsBinaryString, es); | 114 readInternal(blob, FileReaderLoader::ReadAsBinaryString, exceptionState); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void FileReader::readAsText(Blob* blob, const String& encoding, ExceptionState&
es) | 117 void FileReader::readAsText(Blob* blob, const String& encoding, ExceptionState&
exceptionState) |
| 118 { | 118 { |
| 119 if (!blob) | 119 if (!blob) |
| 120 return; | 120 return; |
| 121 | 121 |
| 122 LOG(FileAPI, "FileReader: reading as text: %s %s\n", utf8BlobUUID(blob).data
(), utf8FilePath(blob).data()); | 122 LOG(FileAPI, "FileReader: reading as text: %s %s\n", utf8BlobUUID(blob).data
(), utf8FilePath(blob).data()); |
| 123 | 123 |
| 124 m_encoding = encoding; | 124 m_encoding = encoding; |
| 125 readInternal(blob, FileReaderLoader::ReadAsText, es); | 125 readInternal(blob, FileReaderLoader::ReadAsText, exceptionState); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void FileReader::readAsText(Blob* blob, ExceptionState& es) | 128 void FileReader::readAsText(Blob* blob, ExceptionState& exceptionState) |
| 129 { | 129 { |
| 130 readAsText(blob, String(), es); | 130 readAsText(blob, String(), exceptionState); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void FileReader::readAsDataURL(Blob* blob, ExceptionState& es) | 133 void FileReader::readAsDataURL(Blob* blob, ExceptionState& exceptionState) |
| 134 { | 134 { |
| 135 if (!blob) | 135 if (!blob) |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", utf8BlobUUID(blob).
data(), utf8FilePath(blob).data()); | 138 LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", utf8BlobUUID(blob).
data(), utf8FilePath(blob).data()); |
| 139 | 139 |
| 140 readInternal(blob, FileReaderLoader::ReadAsDataURL, es); | 140 readInternal(blob, FileReaderLoader::ReadAsDataURL, exceptionState); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep
tionState& es) | 143 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep
tionState& exceptionState) |
| 144 { | 144 { |
| 145 // If multiple concurrent read methods are called on the same FileReader, In
validStateError should be thrown when the state is LOADING. | 145 // If multiple concurrent read methods are called on the same FileReader, In
validStateError should be thrown when the state is LOADING. |
| 146 if (m_state == LOADING) { | 146 if (m_state == LOADING) { |
| 147 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 147 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 | 150 |
| 151 setPendingActivity(this); | 151 setPendingActivity(this); |
| 152 | 152 |
| 153 m_blob = blob; | 153 m_blob = blob; |
| 154 m_readType = type; | 154 m_readType = type; |
| 155 m_state = LOADING; | 155 m_state = LOADING; |
| 156 m_loadingState = LoadingStateLoading; | 156 m_loadingState = LoadingStateLoading; |
| 157 m_error = 0; | 157 m_error = 0; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 285 } |
| 286 | 286 |
| 287 String FileReader::stringResult() | 287 String FileReader::stringResult() |
| 288 { | 288 { |
| 289 if (!m_loader || m_error) | 289 if (!m_loader || m_error) |
| 290 return String(); | 290 return String(); |
| 291 return m_loader->stringResult(); | 291 return m_loader->stringResult(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace WebCore | 294 } // namespace WebCore |
| OLD | NEW |