| 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/FetchFormDataConsumerHandle.h" | 5 #include "modules/fetch/FetchFormDataConsumerHandle.h" |
| 6 | 6 |
| 7 #include "modules/fetch/DataConsumerHandleUtil.h" | 7 #include "modules/fetch/DataConsumerHandleUtil.h" |
| 8 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | 8 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| 9 #include "wtf/PtrUtil.h" | 9 #include "wtf/PtrUtil.h" |
| 10 #include "wtf/ThreadingPrimitives.h" | 10 #include "wtf/ThreadingPrimitives.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // Drain blob from the underlying handle to mark data as read. | 230 // Drain blob from the underlying handle to mark data as read. |
| 231 RefPtr<BlobDataHandle> handle = m_reader->drainAsBlobDataHandle(
AllowBlobWithInvalidSize); | 231 RefPtr<BlobDataHandle> handle = m_reader->drainAsBlobDataHandle(
AllowBlobWithInvalidSize); |
| 232 // Here we assume we can always get the valid handle. That is | 232 // Here we assume we can always get the valid handle. That is |
| 233 // in fact not specified at FetchDataConsumerHandle level, but | 233 // in fact not specified at FetchDataConsumerHandle level, but |
| 234 // |m_context->m_handle| is a FetchBlobDataConsumerHandle. | 234 // |m_context->m_handle| is a FetchBlobDataConsumerHandle. |
| 235 ASSERT(handle); | 235 ASSERT(handle); |
| 236 } | 236 } |
| 237 return formData.release(); | 237 return formData.release(); |
| 238 } | 238 } |
| 239 private: | 239 private: |
| 240 ReaderImpl(PassRefPtr<ComplexContext> context, Client* client) : m_conte
xt(context), m_reader(m_context->m_handle->obtainReader(client)) {} | 240 ReaderImpl(PassRefPtr<ComplexContext> context, Client* client) : m_conte
xt(context), m_reader(m_context->m_handle->obtainFetchDataReader(client)) {} |
| 241 | 241 |
| 242 RefPtr<ComplexContext> m_context; | 242 RefPtr<ComplexContext> m_context; |
| 243 std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader; | 243 std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader; |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 ComplexContext(ExecutionContext* executionContext, PassRefPtr<EncodedFormDat
a> body, FetchBlobDataConsumerHandle::LoaderFactory* factory) | 246 ComplexContext(ExecutionContext* executionContext, PassRefPtr<EncodedFormDat
a> body, FetchBlobDataConsumerHandle::LoaderFactory* factory) |
| 247 { | 247 { |
| 248 std::unique_ptr<BlobData> blobData = BlobData::create(); | 248 std::unique_ptr<BlobData> blobData = BlobData::create(); |
| 249 for (const auto& element : body->elements()) { | 249 for (const auto& element : body->elements()) { |
| 250 switch (element.m_type) { | 250 switch (element.m_type) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) | 323 FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) |
| 324 { | 324 { |
| 325 if (isSimple(body.get())) { | 325 if (isSimple(body.get())) { |
| 326 m_context = SimpleContext::create(body); | 326 m_context = SimpleContext::create(body); |
| 327 } else { | 327 } else { |
| 328 m_context = ComplexContext::create(executionContext, body, loaderFactory
); | 328 m_context = ComplexContext::create(executionContext, body, loaderFactory
); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 FetchFormDataConsumerHandle::~FetchFormDataConsumerHandle() {} | 331 FetchFormDataConsumerHandle::~FetchFormDataConsumerHandle() {} |
| 332 | 332 |
| 333 FetchDataConsumerHandle::Reader* FetchFormDataConsumerHandle::obtainReaderIntern
al(Client* client) | 333 std::unique_ptr<FetchDataConsumerHandle::Reader> FetchFormDataConsumerHandle::ob
tainFetchDataReader(Client* client) |
| 334 { | 334 { |
| 335 return m_context->obtainReader(client).release(); | 335 return m_context->obtainReader(client); |
| 336 } | 336 } |
| 337 | 337 |
| 338 } // namespace blink | 338 } // namespace blink |
| OLD | NEW |