| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 cleanup(); | 159 cleanup(); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 void FileReaderLoader::cleanup() | 163 void FileReaderLoader::cleanup() |
| 164 { | 164 { |
| 165 m_loader = nullptr; | 165 m_loader = nullptr; |
| 166 | 166 |
| 167 // If we get any error, we do not need to keep a buffer around. | 167 // If we get any error, we do not need to keep a buffer around. |
| 168 if (m_errorCode) { | 168 if (m_errorCode) { |
| 169 m_rawData.clear(); | 169 m_rawData.reset(); |
| 170 m_stringResult = ""; | 170 m_stringResult = ""; |
| 171 m_isRawDataConverted = true; | 171 m_isRawDataConverted = true; |
| 172 m_decoder.clear(); | 172 m_decoder.reset(); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 void FileReaderLoader::didReceiveResponse(unsigned long, const ResourceResponse&
response, PassOwnPtr<WebDataConsumerHandle> handle) | 176 void FileReaderLoader::didReceiveResponse(unsigned long, const ResourceResponse&
response, PassOwnPtr<WebDataConsumerHandle> handle) |
| 177 { | 177 { |
| 178 ASSERT_UNUSED(handle, !handle); | 178 ASSERT_UNUSED(handle, !handle); |
| 179 if (response.httpStatusCode() != 200) { | 179 if (response.httpStatusCode() != 200) { |
| 180 failed(httpStatusCodeToErrorCode(response.httpStatusCode())); | 180 failed(httpStatusCodeToErrorCode(response.httpStatusCode())); |
| 181 return; | 181 return; |
| 182 } | 182 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 if (m_readType == ReadByClient) { | 241 if (m_readType == ReadByClient) { |
| 242 m_bytesLoaded += dataLength; | 242 m_bytesLoaded += dataLength; |
| 243 | 243 |
| 244 if (m_client) | 244 if (m_client) |
| 245 m_client->didReceiveDataForClient(data, dataLength); | 245 m_client->didReceiveDataForClient(data, dataLength); |
| 246 return; | 246 return; |
| 247 } | 247 } |
| 248 | 248 |
| 249 unsigned bytesAppended = m_rawData->append(data, dataLength); | 249 unsigned bytesAppended = m_rawData->append(data, dataLength); |
| 250 if (!bytesAppended) { | 250 if (!bytesAppended) { |
| 251 m_rawData.clear(); | 251 m_rawData.reset(); |
| 252 m_bytesLoaded = 0; | 252 m_bytesLoaded = 0; |
| 253 failed(FileError::NOT_READABLE_ERR); | 253 failed(FileError::NOT_READABLE_ERR); |
| 254 return; | 254 return; |
| 255 } | 255 } |
| 256 m_bytesLoaded += bytesAppended; | 256 m_bytesLoaded += bytesAppended; |
| 257 m_isRawDataConverted = false; | 257 m_isRawDataConverted = false; |
| 258 | 258 |
| 259 if (m_client) | 259 if (m_client) |
| 260 m_client->didReceiveData(); | 260 m_client->didReceiveData(); |
| 261 } | 261 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 m_stringResult = builder.toString(); | 402 m_stringResult = builder.toString(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void FileReaderLoader::setEncoding(const String& encoding) | 405 void FileReaderLoader::setEncoding(const String& encoding) |
| 406 { | 406 { |
| 407 if (!encoding.isEmpty()) | 407 if (!encoding.isEmpty()) |
| 408 m_encoding = WTF::TextEncoding(encoding); | 408 m_encoding = WTF::TextEncoding(encoding); |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace blink | 411 } // namespace blink |
| OLD | NEW |