Chromium Code Reviews| 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" |
|
tyoshino (SeeGerritForStatus)
2016/03/03 11:53:38
Add OwnPtr.h
hiroshige
2016/03/08 23:39:25
Done.
| |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 using Result = FetchBlobDataConsumerHandle::Result; | 19 using Result = FetchBlobDataConsumerHandle::Result; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Object graph: | 23 // Object graph: |
| 24 // +-------------+ | 24 // +-------------+ |
| 25 // |ReaderContext| | 25 // |ReaderContext| |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 m_loader = createLoader(executionContext, this); | 93 m_loader = createLoader(executionContext, this); |
| 94 ASSERT(m_loader); | 94 ASSERT(m_loader); |
| 95 | 95 |
| 96 ResourceRequest request(url); | 96 ResourceRequest request(url); |
| 97 request.setRequestContext(WebURLRequest::RequestContextInternal); | 97 request.setRequestContext(WebURLRequest::RequestContextInternal); |
| 98 request.setUseStreamOnResponse(true); | 98 request.setUseStreamOnResponse(true); |
| 99 m_loader->start(request); | 99 m_loader->start(request); |
| 100 } | 100 } |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 PassRefPtr<ThreadableLoader> createLoader(ExecutionContext* executionContext , ThreadableLoaderClient* client) const | 103 PassOwnPtr<ThreadableLoader> createLoader(ExecutionContext* executionContext , ThreadableLoaderClient* client) const |
| 104 { | 104 { |
| 105 ThreadableLoaderOptions options; | 105 ThreadableLoaderOptions options; |
| 106 options.preflightPolicy = ConsiderPreflight; | 106 options.preflightPolicy = ConsiderPreflight; |
| 107 options.crossOriginRequestPolicy = DenyCrossOriginRequests; | 107 options.crossOriginRequestPolicy = DenyCrossOriginRequests; |
| 108 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPo licy; | 108 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPo licy; |
| 109 options.initiator = FetchInitiatorTypeNames::internal; | 109 options.initiator = FetchInitiatorTypeNames::internal; |
| 110 | 110 |
| 111 ResourceLoaderOptions resourceLoaderOptions; | 111 ResourceLoaderOptions resourceLoaderOptions; |
| 112 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; | 112 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; |
| 113 | 113 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 144 void didFailRedirectCheck() override | 144 void didFailRedirectCheck() override |
| 145 { | 145 { |
| 146 // We don't expect redirects for Blob loading. | 146 // We don't expect redirects for Blob loading. |
| 147 ASSERT_NOT_REACHED(); | 147 ASSERT_NOT_REACHED(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 Persistent<CompositeDataConsumerHandle::Updater> m_updater; | 150 Persistent<CompositeDataConsumerHandle::Updater> m_updater; |
| 151 | 151 |
| 152 RefPtr<BlobDataHandle> m_blobDataHandle; | 152 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 153 Persistent<FetchBlobDataConsumerHandle::LoaderFactory> m_loaderFactory; | 153 Persistent<FetchBlobDataConsumerHandle::LoaderFactory> m_loaderFactory; |
| 154 RefPtr<ThreadableLoader> m_loader; | 154 OwnPtr<ThreadableLoader> m_loader; |
| 155 | 155 |
| 156 bool m_receivedResponse; | 156 bool m_receivedResponse; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 class DefaultLoaderFactory final : public FetchBlobDataConsumerHandle::LoaderFac tory { | 159 class DefaultLoaderFactory final : public FetchBlobDataConsumerHandle::LoaderFac tory { |
| 160 public: | 160 public: |
| 161 PassRefPtr<ThreadableLoader> create( | 161 PassOwnPtr<ThreadableLoader> create( |
| 162 ExecutionContext& executionContext, | 162 ExecutionContext& executionContext, |
| 163 ThreadableLoaderClient* client, | 163 ThreadableLoaderClient* client, |
| 164 const ThreadableLoaderOptions& options, | 164 const ThreadableLoaderOptions& options, |
| 165 const ResourceLoaderOptions& resourceLoaderOptions) override | 165 const ResourceLoaderOptions& resourceLoaderOptions) override |
| 166 { | 166 { |
| 167 return ThreadableLoader::create(executionContext, client, options, resou rceLoaderOptions); | 167 return ThreadableLoader::create(executionContext, client, options, resou rceLoaderOptions); |
| 168 } | 168 } |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 } // namespace | 171 } // namespace |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 | 304 |
| 305 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa ndle, new DefaultLoaderFactory)); | 305 return adoptPtr(new FetchBlobDataConsumerHandle(executionContext, blobDataHa ndle, new DefaultLoaderFactory)); |
| 306 } | 306 } |
| 307 | 307 |
| 308 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern al(Client* client) | 308 FetchDataConsumerHandle::Reader* FetchBlobDataConsumerHandle::obtainReaderIntern al(Client* client) |
| 309 { | 309 { |
| 310 return m_readerContext->obtainReader(client).leakPtr(); | 310 return m_readerContext->obtainReader(client).leakPtr(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace blink | 313 } // namespace blink |
| OLD | NEW |