| 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(FileAPI, "FileReader: reading as array buffer: %s %s\n", blob->uuid().ut
f8().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(FileAPI, "FileReader: reading as binary: %s %s\n", blob->uuid().utf8().d
ata(), 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(FileAPI, "FileReader: reading as text: %s %s\n", blob->uuid().utf8().dat
a(), 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(FileAPI, "FileReader: reading as data URL: %s %s\n", blob->uuid().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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 fireEvent(eventNames().loadendEvent); | 184 fireEvent(eventNames().loadendEvent); |
| 185 | 185 |
| 186 // All possible events have fired and we're done, no more pending activity. | 186 // All possible events have fired and we're done, no more pending activity. |
| 187 unsetPendingActivity(this); | 187 unsetPendingActivity(this); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void FileReader::terminate() | 190 void FileReader::terminate() |
| 191 { | 191 { |
| 192 if (m_loader) { | 192 if (m_loader) { |
| 193 m_loader->cancel(); | 193 m_loader->cancel(); |
| 194 m_loader = nullptr; | 194 m_loader = 0; |
| 195 } | 195 } |
| 196 m_state = DONE; | 196 m_state = DONE; |
| 197 } | 197 } |
| 198 | 198 |
| 199 void FileReader::didStartLoading() | 199 void FileReader::didStartLoading() |
| 200 { | 200 { |
| 201 fireEvent(eventNames().loadstartEvent); | 201 fireEvent(eventNames().loadstartEvent); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void FileReader::didReceiveData() | 204 void FileReader::didReceiveData() |
| (...skipping 56 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 |