OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/BlobBytesConsumer.h" | 5 #include "modules/fetch/BlobBytesConsumer.h" |
6 | 6 |
7 #include "core/fetch/FetchInitiatorTypeNames.h" | 7 #include "core/fetch/FetchInitiatorTypeNames.h" |
8 #include "core/loader/ThreadableLoader.h" | 8 #include "core/loader/ThreadableLoader.h" |
9 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h" | 9 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h" |
10 #include "platform/blob/BlobData.h" | 10 #include "platform/blob/BlobData.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 if (m_loader) { | 29 if (m_loader) { |
30 m_loader->cancel(); | 30 m_loader->cancel(); |
31 m_loader = nullptr; | 31 m_loader = nullptr; |
32 } | 32 } |
33 m_state = PublicState::Closed; | 33 m_state = PublicState::Closed; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 BlobBytesConsumer::BlobBytesConsumer(ExecutionContext* executionContext, | 37 BlobBytesConsumer::BlobBytesConsumer(ExecutionContext* executionContext, |
38 PassRefPtr<BlobDataHandle> blobDataHandle) | 38 PassRefPtr<BlobDataHandle> blobDataHandle) |
39 : BlobBytesConsumer(executionContext, blobDataHandle, nullptr) {} | 39 : BlobBytesConsumer(executionContext, std::move(blobDataHandle), nullptr) {} |
40 | 40 |
41 BlobBytesConsumer::~BlobBytesConsumer() {} | 41 BlobBytesConsumer::~BlobBytesConsumer() {} |
42 | 42 |
43 BytesConsumer::Result BlobBytesConsumer::beginRead(const char** buffer, | 43 BytesConsumer::Result BlobBytesConsumer::beginRead(const char** buffer, |
44 size_t* available) { | 44 size_t* available) { |
45 *buffer = nullptr; | 45 *buffer = nullptr; |
46 *available = 0; | 46 *available = 0; |
47 | 47 |
48 if (m_state == PublicState::Closed) { | 48 if (m_state == PublicState::Closed) { |
49 // It's possible that |cancel| has been called before the first | 49 // It's possible that |cancel| has been called before the first |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 visitor->trace(m_loader); | 258 visitor->trace(m_loader); |
259 BytesConsumer::trace(visitor); | 259 BytesConsumer::trace(visitor); |
260 BytesConsumer::Client::trace(visitor); | 260 BytesConsumer::Client::trace(visitor); |
261 ContextLifecycleObserver::trace(visitor); | 261 ContextLifecycleObserver::trace(visitor); |
262 } | 262 } |
263 | 263 |
264 BlobBytesConsumer* BlobBytesConsumer::createForTesting( | 264 BlobBytesConsumer* BlobBytesConsumer::createForTesting( |
265 ExecutionContext* executionContext, | 265 ExecutionContext* executionContext, |
266 PassRefPtr<BlobDataHandle> blobDataHandle, | 266 PassRefPtr<BlobDataHandle> blobDataHandle, |
267 ThreadableLoader* loader) { | 267 ThreadableLoader* loader) { |
268 return new BlobBytesConsumer(executionContext, blobDataHandle, loader); | 268 return new BlobBytesConsumer(executionContext, std::move(blobDataHandle), |
| 269 loader); |
269 } | 270 } |
270 | 271 |
271 ThreadableLoader* BlobBytesConsumer::createLoader() { | 272 ThreadableLoader* BlobBytesConsumer::createLoader() { |
272 ThreadableLoaderOptions options; | 273 ThreadableLoaderOptions options; |
273 options.preflightPolicy = ConsiderPreflight; | 274 options.preflightPolicy = ConsiderPreflight; |
274 options.crossOriginRequestPolicy = DenyCrossOriginRequests; | 275 options.crossOriginRequestPolicy = DenyCrossOriginRequests; |
275 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy; | 276 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy; |
276 options.initiator = FetchInitiatorTypeNames::internal; | 277 options.initiator = FetchInitiatorTypeNames::internal; |
277 | 278 |
278 ResourceLoaderOptions resourceLoaderOptions; | 279 ResourceLoaderOptions resourceLoaderOptions; |
(...skipping 18 matching lines...) Expand all Loading... |
297 void BlobBytesConsumer::clear() { | 298 void BlobBytesConsumer::clear() { |
298 DCHECK_NE(m_state, PublicState::ReadableOrWaiting); | 299 DCHECK_NE(m_state, PublicState::ReadableOrWaiting); |
299 if (m_loader) { | 300 if (m_loader) { |
300 m_loader->cancel(); | 301 m_loader->cancel(); |
301 m_loader = nullptr; | 302 m_loader = nullptr; |
302 } | 303 } |
303 m_client = nullptr; | 304 m_client = nullptr; |
304 } | 305 } |
305 | 306 |
306 } // namespace blink | 307 } // namespace blink |
OLD | NEW |