OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/BodyStreamBuffer.h" | 6 #include "modules/fetch/BodyStreamBuffer.h" |
7 | 7 |
8 #include "core/dom/DOMArrayBuffer.h" | 8 #include "core/dom/DOMArrayBuffer.h" |
9 #include "core/dom/DOMTypedArray.h" | 9 #include "core/dom/DOMTypedArray.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
11 #include "modules/fetch/DataConsumerHandleUtil.h" | 11 #include "modules/fetch/DataConsumerHandleUtil.h" |
12 #include "platform/blob/BlobData.h" | 12 #include "platform/blob/BlobData.h" |
| 13 #include "platform/network/FormData.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class BodyStreamBuffer::LoaderHolder final : public GarbageCollectedFinalized<Lo
aderHolder>, public ActiveDOMObject, public FetchDataLoader::Client { | 17 class BodyStreamBuffer::LoaderHolder final : public GarbageCollectedFinalized<Lo
aderHolder>, public ActiveDOMObject, public FetchDataLoader::Client { |
17 WTF_MAKE_NONCOPYABLE(LoaderHolder); | 18 WTF_MAKE_NONCOPYABLE(LoaderHolder); |
18 USING_GARBAGE_COLLECTED_MIXIN(LoaderHolder); | 19 USING_GARBAGE_COLLECTED_MIXIN(LoaderHolder); |
19 public: | 20 public: |
20 LoaderHolder(ExecutionContext* executionContext, BodyStreamBuffer* buffer, F
etchDataLoader* loader, FetchDataLoader::Client* client) | 21 LoaderHolder(ExecutionContext* executionContext, BodyStreamBuffer* buffer, F
etchDataLoader* loader, FetchDataLoader::Client* client) |
21 : ActiveDOMObject(executionContext) | 22 : ActiveDOMObject(executionContext) |
22 , m_buffer(buffer) | 23 , m_buffer(buffer) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return nullptr; | 111 return nullptr; |
111 | 112 |
112 RefPtr<BlobDataHandle> blobDataHandle = m_reader->drainAsBlobDataHandle(poli
cy); | 113 RefPtr<BlobDataHandle> blobDataHandle = m_reader->drainAsBlobDataHandle(poli
cy); |
113 if (blobDataHandle) { | 114 if (blobDataHandle) { |
114 close(); | 115 close(); |
115 return blobDataHandle.release(); | 116 return blobDataHandle.release(); |
116 } | 117 } |
117 return nullptr; | 118 return nullptr; |
118 } | 119 } |
119 | 120 |
| 121 PassRefPtr<FormData> BodyStreamBuffer::drainAsFormData() |
| 122 { |
| 123 ASSERT(!isLocked()); |
| 124 if (ReadableStream::Closed == m_stream->stateInternal() || ReadableStream::E
rrored == m_stream->stateInternal()) |
| 125 return nullptr; |
| 126 |
| 127 RefPtr<FormData> formData = m_reader->drainAsFormData(); |
| 128 if (formData) { |
| 129 close(); |
| 130 return formData.release(); |
| 131 } |
| 132 return nullptr; |
| 133 } |
| 134 |
120 PassOwnPtr<FetchDataConsumerHandle> BodyStreamBuffer::lock(ExecutionContext* exe
cutionContext) | 135 PassOwnPtr<FetchDataConsumerHandle> BodyStreamBuffer::lock(ExecutionContext* exe
cutionContext) |
121 { | 136 { |
122 ASSERT(!isLocked()); | 137 ASSERT(!isLocked()); |
123 ++m_lockLevel; | 138 ++m_lockLevel; |
124 m_reader = nullptr; | 139 m_reader = nullptr; |
125 OwnPtr<FetchDataConsumerHandle> handle = m_handle.release(); | 140 OwnPtr<FetchDataConsumerHandle> handle = m_handle.release(); |
126 if (ReadableStream::Closed == m_stream->stateInternal() || !m_hasBody) | 141 if (ReadableStream::Closed == m_stream->stateInternal() || !m_hasBody) |
127 return createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumer
Handle()); | 142 return createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumer
Handle()); |
128 if (ReadableStream::Errored == m_stream->stateInternal()) | 143 if (ReadableStream::Errored == m_stream->stateInternal()) |
129 return createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorD
ataConsumerHandle()); | 144 return createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorD
ataConsumerHandle()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 unlock(); | 254 unlock(); |
240 if (mode == EndLoadingDone) { | 255 if (mode == EndLoadingDone) { |
241 close(); | 256 close(); |
242 } else { | 257 } else { |
243 ASSERT(mode == EndLoadingErrored); | 258 ASSERT(mode == EndLoadingErrored); |
244 error(); | 259 error(); |
245 } | 260 } |
246 } | 261 } |
247 | 262 |
248 } // namespace blink | 263 } // namespace blink |
OLD | NEW |