| 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/FetchBlobDataConsumerHandle.h" | 5 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| 6 | 6 |
| 7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
| 8 #include "core/fetch/FetchInitiatorTypeNames.h" | 8 #include "core/fetch/FetchInitiatorTypeNames.h" |
| 9 #include "core/loader/ThreadableLoaderClient.h" | 9 #include "core/loader/ThreadableLoaderClient.h" |
| 10 #include "modules/fetch/CompositeDataConsumerHandle.h" | 10 #include "modules/fetch/CompositeDataConsumerHandle.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 , m_blobDataHandle(blobDataHandle) | 68 , m_blobDataHandle(blobDataHandle) |
| 69 , m_loaderFactory(loaderFactory) | 69 , m_loaderFactory(loaderFactory) |
| 70 , m_receivedResponse(false) { } | 70 , m_receivedResponse(false) { } |
| 71 | 71 |
| 72 ~BlobLoaderContext() override | 72 ~BlobLoaderContext() override |
| 73 { | 73 { |
| 74 if (m_loader && !m_receivedResponse) | 74 if (m_loader && !m_receivedResponse) |
| 75 m_updater->update(createUnexpectedErrorDataConsumerHandle()); | 75 m_updater->update(createUnexpectedErrorDataConsumerHandle()); |
| 76 if (m_loader) { | 76 if (m_loader) { |
| 77 m_loader->cancel(); | 77 m_loader->cancel(); |
| 78 m_loader.clear(); | 78 m_loader.reset(); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void start(ExecutionContext* executionContext) override | 82 void start(ExecutionContext* executionContext) override |
| 83 { | 83 { |
| 84 ASSERT(executionContext->isContextThread()); | 84 ASSERT(executionContext->isContextThread()); |
| 85 ASSERT(!m_loader); | 85 ASSERT(!m_loader); |
| 86 | 86 |
| 87 KURL url = BlobURL::createPublicURL(executionContext->getSecurityOrigin(
)); | 87 KURL url = BlobURL::createPublicURL(executionContext->getSecurityOrigin(
)); |
| 88 if (url.isEmpty()) { | 88 if (url.isEmpty()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // |WebDataConsumerHandle| since we call | 126 // |WebDataConsumerHandle| since we call |
| 127 // request.setUseStreamOnResponse(). | 127 // request.setUseStreamOnResponse(). |
| 128 m_updater->update(createUnexpectedErrorDataConsumerHandle()); | 128 m_updater->update(createUnexpectedErrorDataConsumerHandle()); |
| 129 return; | 129 return; |
| 130 } | 130 } |
| 131 m_updater->update(std::move(handle)); | 131 m_updater->update(std::move(handle)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void didFinishLoading(unsigned long, double) override | 134 void didFinishLoading(unsigned long, double) override |
| 135 { | 135 { |
| 136 m_loader.clear(); | 136 m_loader.reset(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void didFail(const ResourceError&) override | 139 void didFail(const ResourceError&) override |
| 140 { | 140 { |
| 141 if (!m_receivedResponse) | 141 if (!m_receivedResponse) |
| 142 m_updater->update(createUnexpectedErrorDataConsumerHandle()); | 142 m_updater->update(createUnexpectedErrorDataConsumerHandle()); |
| 143 m_loader.clear(); | 143 m_loader.reset(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void didFailRedirectCheck() override | 146 void didFailRedirectCheck() override |
| 147 { | 147 { |
| 148 // We don't expect redirects for Blob loading. | 148 // We don't expect redirects for Blob loading. |
| 149 ASSERT_NOT_REACHED(); | 149 ASSERT_NOT_REACHED(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 Persistent<CompositeDataConsumerHandle::Updater> m_updater; | 152 Persistent<CompositeDataConsumerHandle::Updater> m_updater; |
| 153 | 153 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa
ndle, new DefaultLoaderFactory)); | 307 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa
ndle, new DefaultLoaderFactory)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern
al(Client* client) | 310 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern
al(Client* client) |
| 311 { | 311 { |
| 312 return m_readerContext->obtainReader(client).leakPtr(); | 312 return m_readerContext->obtainReader(client).leakPtr(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 } // namespace blink | 315 } // namespace blink |
| OLD | NEW |