| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void FileReader::stop() | 83 void FileReader::stop() |
| 84 { | 84 { |
| 85 terminate(); | 85 terminate(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void FileReader::readAsArrayBuffer(Blob* blob, ExceptionCode& ec) | 88 void FileReader::readAsArrayBuffer(Blob* blob, ExceptionCode& ec) |
| 89 { | 89 { |
| 90 if (!blob) | 90 if (!blob) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 LOG(FileAPI, "FileReader: reading as array buffer: %s %s\n", blob->url().str
ing().utf8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() : ""); | 93 LOG_INFO(FileAPI, "FileReader: reading as array buffer: %s %s\n", blob->url(
).string().utf8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() :
""); |
| 94 | 94 |
| 95 readInternal(blob, FileReaderLoader::ReadAsArrayBuffer, ec); | 95 readInternal(blob, FileReaderLoader::ReadAsArrayBuffer, ec); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void FileReader::readAsBinaryString(Blob* blob, ExceptionCode& ec) | 98 void FileReader::readAsBinaryString(Blob* blob, ExceptionCode& ec) |
| 99 { | 99 { |
| 100 if (!blob) | 100 if (!blob) |
| 101 return; | 101 return; |
| 102 | 102 |
| 103 LOG(FileAPI, "FileReader: reading as binary: %s %s\n", blob->url().string().
utf8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() : ""); | 103 LOG_INFO(FileAPI, "FileReader: reading as binary: %s %s\n", blob->url().stri
ng().utf8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() : ""); |
| 104 | 104 |
| 105 readInternal(blob, FileReaderLoader::ReadAsBinaryString, ec); | 105 readInternal(blob, FileReaderLoader::ReadAsBinaryString, ec); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void FileReader::readAsText(Blob* blob, const String& encoding, ExceptionCode& e
c) | 108 void FileReader::readAsText(Blob* blob, const String& encoding, ExceptionCode& e
c) |
| 109 { | 109 { |
| 110 if (!blob) | 110 if (!blob) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 LOG(FileAPI, "FileReader: reading as text: %s %s\n", blob->url().string().ut
f8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() : ""); | 113 LOG_INFO(FileAPI, "FileReader: reading as text: %s %s\n", blob->url().string
().utf8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() : ""); |
| 114 | 114 |
| 115 m_encoding = encoding; | 115 m_encoding = encoding; |
| 116 readInternal(blob, FileReaderLoader::ReadAsText, ec); | 116 readInternal(blob, FileReaderLoader::ReadAsText, ec); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void FileReader::readAsText(Blob* blob, ExceptionCode& ec) | 119 void FileReader::readAsText(Blob* blob, ExceptionCode& ec) |
| 120 { | 120 { |
| 121 readAsText(blob, String(), ec); | 121 readAsText(blob, String(), ec); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void FileReader::readAsDataURL(Blob* blob, ExceptionCode& ec) | 124 void FileReader::readAsDataURL(Blob* blob, ExceptionCode& ec) |
| 125 { | 125 { |
| 126 if (!blob) | 126 if (!blob) |
| 127 return; | 127 return; |
| 128 | 128 |
| 129 LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", blob->url().string(
).utf8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() : ""); | 129 LOG_INFO(FileAPI, "FileReader: reading as data URL: %s %s\n", blob->url().st
ring().utf8().data(), blob->isFile() ? toFile(blob)->path().utf8().data() : ""); |
| 130 | 130 |
| 131 readInternal(blob, FileReaderLoader::ReadAsDataURL, ec); | 131 readInternal(blob, FileReaderLoader::ReadAsDataURL, ec); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep
tionCode& ec) | 134 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep
tionCode& ec) |
| 135 { | 135 { |
| 136 // If multiple concurrent read methods are called on the same FileReader, IN
VALID_STATE_ERR should be thrown when the state is LOADING. | 136 // If multiple concurrent read methods are called on the same FileReader, IN
VALID_STATE_ERR should be thrown when the state is LOADING. |
| 137 if (m_state == LOADING) { | 137 if (m_state == LOADING) { |
| 138 ec = INVALID_STATE_ERR; | 138 ec = INVALID_STATE_ERR; |
| 139 return; | 139 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 152 m_loader->start(scriptExecutionContext(), m_blob.get()); | 152 m_loader->start(scriptExecutionContext(), m_blob.get()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 static void delayedAbort(ScriptExecutionContext*, FileReader* reader) | 155 static void delayedAbort(ScriptExecutionContext*, FileReader* reader) |
| 156 { | 156 { |
| 157 reader->doAbort(); | 157 reader->doAbort(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void FileReader::abort() | 160 void FileReader::abort() |
| 161 { | 161 { |
| 162 LOG(FileAPI, "FileReader: aborting\n"); | 162 LOG_INFO(FileAPI, "FileReader: aborting\n"); |
| 163 | 163 |
| 164 if (m_aborting || m_state != LOADING) | 164 if (m_aborting || m_state != LOADING) |
| 165 return; | 165 return; |
| 166 m_aborting = true; | 166 m_aborting = true; |
| 167 | 167 |
| 168 // Schedule to have the abort done later since abort() might be called from
the event handler and we do not want the resource loading code to be in the stac
k. | 168 // Schedule to have the abort done later since abort() might be called from
the event handler and we do not want the resource loading code to be in the stac
k. |
| 169 scriptExecutionContext()->postTask( | 169 scriptExecutionContext()->postTask( |
| 170 createCallbackTask(&delayedAbort, AllowAccessLater(this))); | 170 createCallbackTask(&delayedAbort, AllowAccessLater(this))); |
| 171 } | 171 } |
| 172 | 172 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 String FileReader::stringResult() | 261 String FileReader::stringResult() |
| 262 { | 262 { |
| 263 if (!m_loader || m_error) | 263 if (!m_loader || m_error) |
| 264 return String(); | 264 return String(); |
| 265 return m_loader->stringResult(); | 265 return m_loader->stringResult(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace WebCore | 268 } // namespace WebCore |
| 269 | 269 |
| 270 #endif // ENABLE(BLOB) | 270 #endif // ENABLE(BLOB) |
| OLD | NEW |