| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/fetch/FetchDataLoader.h" | 6 #include "modules/fetch/FetchDataLoader.h" |
| 7 | 7 |
| 8 #include "wtf/ArrayBufferBuilder.h" | 8 #include "wtf/ArrayBufferBuilder.h" |
| 9 #include "wtf/text/WTFString.h" | 9 #include "wtf/text/WTFString.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } else { | 45 } else { |
| 46 m_client->didFetchDataLoadedBlobHandle(blobHandle); | 46 m_client->didFetchDataLoadedBlobHandle(blobHandle); |
| 47 } | 47 } |
| 48 m_client.clear(); | 48 m_client.clear(); |
| 49 return; | 49 return; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // We read data from |m_reader| and create a new blob. | 52 // We read data from |m_reader| and create a new blob. |
| 53 m_blobData = BlobData::create(); | 53 m_blobData = BlobData::create(); |
| 54 m_blobData->setContentType(m_mimeType); | 54 m_blobData->setContentType(m_mimeType); |
| 55 didGetReadable(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 void didGetReadable() override | 58 void didGetReadable() override |
| 58 { | 59 { |
| 59 ASSERT(m_client); | 60 ASSERT(m_client); |
| 60 ASSERT(m_reader); | 61 ASSERT(m_reader); |
| 61 | 62 |
| 62 while (true) { | 63 while (true) { |
| 63 const void* buffer; | 64 const void* buffer; |
| 64 size_t available; | 65 size_t available; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 130 |
| 130 protected: | 131 protected: |
| 131 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override | 132 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override |
| 132 { | 133 { |
| 133 ASSERT(!m_client); | 134 ASSERT(!m_client); |
| 134 ASSERT(!m_rawData); | 135 ASSERT(!m_rawData); |
| 135 ASSERT(!m_reader); | 136 ASSERT(!m_reader); |
| 136 m_client = client; | 137 m_client = client; |
| 137 m_rawData = adoptPtr(new ArrayBufferBuilder()); | 138 m_rawData = adoptPtr(new ArrayBufferBuilder()); |
| 138 m_reader = handle->obtainReader(this); | 139 m_reader = handle->obtainReader(this); |
| 140 didGetReadable(); |
| 139 } | 141 } |
| 140 | 142 |
| 141 void didGetReadable() override | 143 void didGetReadable() override |
| 142 { | 144 { |
| 143 ASSERT(m_client); | 145 ASSERT(m_client); |
| 144 ASSERT(m_rawData); | 146 ASSERT(m_rawData); |
| 145 ASSERT(m_reader); | 147 ASSERT(m_reader); |
| 146 | 148 |
| 147 while (true) { | 149 while (true) { |
| 148 const void* buffer; | 150 const void* buffer; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 visitor->trace(m_outStream); | 229 visitor->trace(m_outStream); |
| 228 } | 230 } |
| 229 | 231 |
| 230 protected: | 232 protected: |
| 231 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override | 233 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client)
override |
| 232 { | 234 { |
| 233 ASSERT(!m_client); | 235 ASSERT(!m_client); |
| 234 ASSERT(!m_reader); | 236 ASSERT(!m_reader); |
| 235 m_client = client; | 237 m_client = client; |
| 236 m_reader = handle->obtainReader(this); | 238 m_reader = handle->obtainReader(this); |
| 239 didGetReadable(); |
| 237 } | 240 } |
| 238 | 241 |
| 239 void didGetReadable() override | 242 void didGetReadable() override |
| 240 { | 243 { |
| 241 ASSERT(m_client); | 244 ASSERT(m_client); |
| 242 ASSERT(m_reader); | 245 ASSERT(m_reader); |
| 243 | 246 |
| 244 bool needToFlush = false; | 247 bool needToFlush = false; |
| 245 while (true) { | 248 while (true) { |
| 246 const void* buffer; | 249 const void* buffer; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 { | 323 { |
| 321 return new FetchDataLoaderAsArrayBufferOrString(FetchDataLoaderAsArrayBuffer
OrString::LoadAsString); | 324 return new FetchDataLoaderAsArrayBufferOrString(FetchDataLoaderAsArrayBuffer
OrString::LoadAsString); |
| 322 } | 325 } |
| 323 | 326 |
| 324 FetchDataLoader* FetchDataLoader::createLoaderAsStream(Stream* outStream) | 327 FetchDataLoader* FetchDataLoader::createLoaderAsStream(Stream* outStream) |
| 325 { | 328 { |
| 326 return new FetchDataLoaderAsStream(outStream); | 329 return new FetchDataLoaderAsStream(outStream); |
| 327 } | 330 } |
| 328 | 331 |
| 329 } // namespace blink | 332 } // namespace blink |
| OLD | NEW |