| 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" |
| 11 #include "modules/fetch/CrossThreadHolder.h" | 11 #include "modules/fetch/CrossThreadHolder.h" |
| 12 #include "modules/fetch/DataConsumerHandleUtil.h" | 12 #include "modules/fetch/DataConsumerHandleUtil.h" |
| 13 #include "platform/blob/BlobRegistry.h" | 13 #include "platform/blob/BlobRegistry.h" |
| 14 #include "platform/blob/BlobURL.h" | 14 #include "platform/blob/BlobURL.h" |
| 15 #include "platform/network/ResourceRequest.h" | 15 #include "platform/network/ResourceRequest.h" |
| 16 #include "wtf/OwnPtr.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 using Result = FetchBlobDataConsumerHandle::Result; | 20 using Result = FetchBlobDataConsumerHandle::Result; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Object graph: | 24 // Object graph: |
| 24 // +-------------+ | 25 // +-------------+ |
| 25 // |ReaderContext| | 26 // |ReaderContext| |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 ASSERT(m_loader); | 95 ASSERT(m_loader); |
| 95 | 96 |
| 96 ResourceRequest request(url); | 97 ResourceRequest request(url); |
| 97 request.setRequestContext(WebURLRequest::RequestContextInternal); | 98 request.setRequestContext(WebURLRequest::RequestContextInternal); |
| 98 request.setUseStreamOnResponse(true); | 99 request.setUseStreamOnResponse(true); |
| 99 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpa
ce', as 'data:' can never be external. | 100 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpa
ce', as 'data:' can never be external. |
| 100 m_loader->start(request); | 101 m_loader->start(request); |
| 101 } | 102 } |
| 102 | 103 |
| 103 private: | 104 private: |
| 104 PassRefPtr<ThreadableLoader> createLoader(ExecutionContext* executionContext
, ThreadableLoaderClient* client) const | 105 PassOwnPtr<ThreadableLoader> createLoader(ExecutionContext* executionContext
, ThreadableLoaderClient* client) const |
| 105 { | 106 { |
| 106 ThreadableLoaderOptions options; | 107 ThreadableLoaderOptions options; |
| 107 options.preflightPolicy = ConsiderPreflight; | 108 options.preflightPolicy = ConsiderPreflight; |
| 108 options.crossOriginRequestPolicy = DenyCrossOriginRequests; | 109 options.crossOriginRequestPolicy = DenyCrossOriginRequests; |
| 109 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPo
licy; | 110 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPo
licy; |
| 110 options.initiator = FetchInitiatorTypeNames::internal; | 111 options.initiator = FetchInitiatorTypeNames::internal; |
| 111 | 112 |
| 112 ResourceLoaderOptions resourceLoaderOptions; | 113 ResourceLoaderOptions resourceLoaderOptions; |
| 113 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; | 114 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; |
| 114 | 115 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 145 void didFailRedirectCheck() override | 146 void didFailRedirectCheck() override |
| 146 { | 147 { |
| 147 // We don't expect redirects for Blob loading. | 148 // We don't expect redirects for Blob loading. |
| 148 ASSERT_NOT_REACHED(); | 149 ASSERT_NOT_REACHED(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 Persistent<CompositeDataConsumerHandle::Updater> m_updater; | 152 Persistent<CompositeDataConsumerHandle::Updater> m_updater; |
| 152 | 153 |
| 153 RefPtr<BlobDataHandle> m_blobDataHandle; | 154 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 154 Persistent<FetchBlobDataConsumerHandle::LoaderFactory> m_loaderFactory; | 155 Persistent<FetchBlobDataConsumerHandle::LoaderFactory> m_loaderFactory; |
| 155 RefPtr<ThreadableLoader> m_loader; | 156 OwnPtr<ThreadableLoader> m_loader; |
| 156 | 157 |
| 157 bool m_receivedResponse; | 158 bool m_receivedResponse; |
| 158 }; | 159 }; |
| 159 | 160 |
| 160 class DefaultLoaderFactory final : public FetchBlobDataConsumerHandle::LoaderFac
tory { | 161 class DefaultLoaderFactory final : public FetchBlobDataConsumerHandle::LoaderFac
tory { |
| 161 public: | 162 public: |
| 162 PassRefPtr<ThreadableLoader> create( | 163 PassOwnPtr<ThreadableLoader> create( |
| 163 ExecutionContext& executionContext, | 164 ExecutionContext& executionContext, |
| 164 ThreadableLoaderClient* client, | 165 ThreadableLoaderClient* client, |
| 165 const ThreadableLoaderOptions& options, | 166 const ThreadableLoaderOptions& options, |
| 166 const ResourceLoaderOptions& resourceLoaderOptions) override | 167 const ResourceLoaderOptions& resourceLoaderOptions) override |
| 167 { | 168 { |
| 168 return ThreadableLoader::create(executionContext, client, options, resou
rceLoaderOptions); | 169 return ThreadableLoader::create(executionContext, client, options, resou
rceLoaderOptions); |
| 169 } | 170 } |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 } // namespace | 173 } // namespace |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 306 |
| 306 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa
ndle, new DefaultLoaderFactory)); | 307 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa
ndle, new DefaultLoaderFactory)); |
| 307 } | 308 } |
| 308 | 309 |
| 309 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern
al(Client* client) | 310 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern
al(Client* client) |
| 310 { | 311 { |
| 311 return m_readerContext->obtainReader(client).leakPtr(); | 312 return m_readerContext->obtainReader(client).leakPtr(); |
| 312 } | 313 } |
| 313 | 314 |
| 314 } // namespace blink | 315 } // namespace blink |
| OLD | NEW |