| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/fetch/FetchDataLoader.h" | 5 #include "modules/fetch/FetchDataLoader.h" |
| 6 | 6 |
| 7 #include "core/html/parser/TextResourceDecoder.h" | 7 #include "core/html/parser/TextResourceDecoder.h" |
| 8 #include "wtf/PtrUtil.h" | 8 #include "wtf/PtrUtil.h" |
| 9 #include "wtf/text/StringBuilder.h" | 9 #include "wtf/text/StringBuilder.h" |
| 10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override | 33 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override |
| 34 { | 34 { |
| 35 ASSERT(!m_client); | 35 ASSERT(!m_client); |
| 36 ASSERT(!m_reader); | 36 ASSERT(!m_reader); |
| 37 | 37 |
| 38 m_client = client; | 38 m_client = client; |
| 39 // Passing |this| here is safe because |this| owns |m_reader|. | 39 // Passing |this| here is safe because |this| owns |m_reader|. |
| 40 m_reader = handle->obtainReader(this); | 40 m_reader = handle->obtainFetchDataReader(this); |
| 41 RefPtr<BlobDataHandle> blobHandle = m_reader->drainAsBlobDataHandle(); | 41 RefPtr<BlobDataHandle> blobHandle = m_reader->drainAsBlobDataHandle(); |
| 42 if (blobHandle) { | 42 if (blobHandle) { |
| 43 ASSERT(blobHandle->size() != UINT64_MAX); | 43 ASSERT(blobHandle->size() != UINT64_MAX); |
| 44 m_reader.reset(); | 44 m_reader.reset(); |
| 45 if (blobHandle->type() != m_mimeType) { | 45 if (blobHandle->type() != m_mimeType) { |
| 46 // A new BlobDataHandle is created to override the Blob's type. | 46 // A new BlobDataHandle is created to override the Blob's type. |
| 47 m_client->didFetchDataLoadedBlobHandle(BlobDataHandle::create(bl
obHandle->uuid(), m_mimeType, blobHandle->size())); | 47 m_client->didFetchDataLoadedBlobHandle(BlobDataHandle::create(bl
obHandle->uuid(), m_mimeType, blobHandle->size())); |
| 48 } else { | 48 } else { |
| 49 m_client->didFetchDataLoadedBlobHandle(blobHandle); | 49 m_client->didFetchDataLoadedBlobHandle(blobHandle); |
| 50 } | 50 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 protected: | 126 protected: |
| 127 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override | 127 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override |
| 128 { | 128 { |
| 129 ASSERT(!m_client); | 129 ASSERT(!m_client); |
| 130 ASSERT(!m_rawData); | 130 ASSERT(!m_rawData); |
| 131 ASSERT(!m_reader); | 131 ASSERT(!m_reader); |
| 132 m_client = client; | 132 m_client = client; |
| 133 m_rawData = wrapUnique(new ArrayBufferBuilder()); | 133 m_rawData = wrapUnique(new ArrayBufferBuilder()); |
| 134 m_reader = handle->obtainReader(this); | 134 m_reader = handle->obtainFetchDataReader(this); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void didGetReadable() override | 137 void didGetReadable() override |
| 138 { | 138 { |
| 139 ASSERT(m_client); | 139 ASSERT(m_client); |
| 140 ASSERT(m_rawData); | 140 ASSERT(m_rawData); |
| 141 ASSERT(m_reader); | 141 ASSERT(m_reader); |
| 142 | 142 |
| 143 while (true) { | 143 while (true) { |
| 144 const void* buffer; | 144 const void* buffer; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 | 214 |
| 215 protected: | 215 protected: |
| 216 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override | 216 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override |
| 217 { | 217 { |
| 218 ASSERT(!m_client); | 218 ASSERT(!m_client); |
| 219 ASSERT(!m_decoder); | 219 ASSERT(!m_decoder); |
| 220 ASSERT(!m_reader); | 220 ASSERT(!m_reader); |
| 221 m_client = client; | 221 m_client = client; |
| 222 m_decoder = TextResourceDecoder::createAlwaysUseUTF8ForText(); | 222 m_decoder = TextResourceDecoder::createAlwaysUseUTF8ForText(); |
| 223 m_reader = handle->obtainReader(this); | 223 m_reader = handle->obtainFetchDataReader(this); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void didGetReadable() override | 226 void didGetReadable() override |
| 227 { | 227 { |
| 228 ASSERT(m_client); | 228 ASSERT(m_client); |
| 229 ASSERT(m_decoder); | 229 ASSERT(m_decoder); |
| 230 ASSERT(m_reader); | 230 ASSERT(m_reader); |
| 231 | 231 |
| 232 while (true) { | 232 while (true) { |
| 233 const void* buffer; | 233 const void* buffer; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 visitor->trace(m_client); | 300 visitor->trace(m_client); |
| 301 visitor->trace(m_outStream); | 301 visitor->trace(m_outStream); |
| 302 } | 302 } |
| 303 | 303 |
| 304 protected: | 304 protected: |
| 305 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override | 305 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override |
| 306 { | 306 { |
| 307 ASSERT(!m_client); | 307 ASSERT(!m_client); |
| 308 ASSERT(!m_reader); | 308 ASSERT(!m_reader); |
| 309 m_client = client; | 309 m_client = client; |
| 310 m_reader = handle->obtainReader(this); | 310 m_reader = handle->obtainFetchDataReader(this); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void didGetReadable() override | 313 void didGetReadable() override |
| 314 { | 314 { |
| 315 ASSERT(m_client); | 315 ASSERT(m_client); |
| 316 ASSERT(m_reader); | 316 ASSERT(m_reader); |
| 317 | 317 |
| 318 bool needToFlush = false; | 318 bool needToFlush = false; |
| 319 while (true) { | 319 while (true) { |
| 320 const void* buffer; | 320 const void* buffer; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 { | 394 { |
| 395 return new FetchDataLoaderAsString(); | 395 return new FetchDataLoaderAsString(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 FetchDataLoader* FetchDataLoader::createLoaderAsStream(Stream* outStream) | 398 FetchDataLoader* FetchDataLoader::createLoaderAsStream(Stream* outStream) |
| 399 { | 399 { |
| 400 return new FetchDataLoaderAsStream(outStream); | 400 return new FetchDataLoaderAsStream(outStream); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace blink | 403 } // namespace blink |
| OLD | NEW |