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/FetchBlobDataConsumerHandle.h" | 6 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
7 | 7 |
8 #include "core/dom/ActiveDOMObject.h" | 8 #include "core/dom/ActiveDOMObject.h" |
9 #include "core/dom/CrossThreadTask.h" | 9 #include "core/dom/CrossThreadTask.h" |
10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 if (!m_readerContext->m_blobDataHandleForDrain) | 383 if (!m_readerContext->m_blobDataHandleForDrain) |
384 return nullptr; | 384 return nullptr; |
385 if (blobSizePolicy == DisallowBlobWithInvalidSize && m_readerContext
->m_blobDataHandleForDrain->size() == kuint64max) | 385 if (blobSizePolicy == DisallowBlobWithInvalidSize && m_readerContext
->m_blobDataHandleForDrain->size() == kuint64max) |
386 return nullptr; | 386 return nullptr; |
387 RefPtr<BlobDataHandle> blobDataHandle = m_readerContext->m_blobDataH
andleForDrain; | 387 RefPtr<BlobDataHandle> blobDataHandle = m_readerContext->m_blobDataH
andleForDrain; |
388 m_readerContext->setDrained(); | 388 m_readerContext->setDrained(); |
389 m_readerContext->clearBlobDataHandleForDrain(); | 389 m_readerContext->clearBlobDataHandleForDrain(); |
390 return blobDataHandle.release(); | 390 return blobDataHandle.release(); |
391 } | 391 } |
392 | 392 |
| 393 PassRefPtr<FormData> drainAsFormData() override |
| 394 { |
| 395 RefPtr<BlobDataHandle> handle = drainAsBlobDataHandle(AllowBlobWithI
nvalidSize); |
| 396 if (!handle) |
| 397 return nullptr; |
| 398 RefPtr<FormData> formData = FormData::create(); |
| 399 formData->appendBlob(handle->uuid(), handle); |
| 400 return formData.release(); |
| 401 } |
| 402 |
393 private: | 403 private: |
394 RefPtr<ReaderContext> m_readerContext; | 404 RefPtr<ReaderContext> m_readerContext; |
395 OwnPtr<WebDataConsumerHandle::Reader> m_reader; | 405 OwnPtr<WebDataConsumerHandle::Reader> m_reader; |
396 NotifyOnReaderCreationHelper m_notifier; | 406 NotifyOnReaderCreationHelper m_notifier; |
397 }; | 407 }; |
398 | 408 |
399 ReaderContext(ExecutionContext* executionContext, PassRefPtr<BlobDataHandle>
blobDataHandle, FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) | 409 ReaderContext(ExecutionContext* executionContext, PassRefPtr<BlobDataHandle>
blobDataHandle, FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) |
400 : m_blobDataHandleForDrain(blobDataHandle) | 410 : m_blobDataHandleForDrain(blobDataHandle) |
401 , m_loaderStarted(false) | 411 , m_loaderStarted(false) |
402 , m_drained(false) | 412 , m_drained(false) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 470 |
461 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa
ndle, new DefaultLoaderFactory)); | 471 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa
ndle, new DefaultLoaderFactory)); |
462 } | 472 } |
463 | 473 |
464 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern
al(Client* client) | 474 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern
al(Client* client) |
465 { | 475 { |
466 return m_readerContext->obtainReader(client).leakPtr(); | 476 return m_readerContext->obtainReader(client).leakPtr(); |
467 } | 477 } |
468 | 478 |
469 } // namespace blink | 479 } // namespace blink |
OLD | NEW |