| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/fetch/DataConsumerTee.h" | 6 #include "modules/fetch/DataConsumerTee.h" |
| 7 | 7 |
| 8 #include "core/dom/ActiveDOMObject.h" | 8 #include "core/dom/ActiveDOMObject.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "modules/fetch/DataConsumerHandleUtil.h" |
| 11 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| 10 #include "platform/Task.h" | 12 #include "platform/Task.h" |
| 11 #include "platform/ThreadSafeFunctional.h" | 13 #include "platform/ThreadSafeFunctional.h" |
| 12 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
| 13 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
| 14 #include "public/platform/WebThread.h" | 16 #include "public/platform/WebThread.h" |
| 15 #include "public/platform/WebTraceLocation.h" | 17 #include "public/platform/WebTraceLocation.h" |
| 16 #include "wtf/Deque.h" | 18 #include "wtf/Deque.h" |
| 17 #include "wtf/Functional.h" | 19 #include "wtf/Functional.h" |
| 18 #include "wtf/ThreadSafeRefCounted.h" | 20 #include "wtf/ThreadSafeRefCounted.h" |
| 19 #include "wtf/ThreadingPrimitives.h" | 21 #include "wtf/ThreadingPrimitives.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 RefPtr<DestinationTracker> tracker = DestinationTracker::create(root); | 417 RefPtr<DestinationTracker> tracker = DestinationTracker::create(root); |
| 416 RefPtr<DestinationContext> context1 = DestinationContext::create(); | 418 RefPtr<DestinationContext> context1 = DestinationContext::create(); |
| 417 RefPtr<DestinationContext> context2 = DestinationContext::create(); | 419 RefPtr<DestinationContext> context2 = DestinationContext::create(); |
| 418 | 420 |
| 419 root->initialize(new SourceContext(root, src, context1, context2, executionC
ontext)); | 421 root->initialize(new SourceContext(root, src, context1, context2, executionC
ontext)); |
| 420 | 422 |
| 421 *dest1 = adoptPtr(new DestinationHandle(DestinationContext::Proxy::create(co
ntext1, tracker))); | 423 *dest1 = adoptPtr(new DestinationHandle(DestinationContext::Proxy::create(co
ntext1, tracker))); |
| 422 *dest2 = adoptPtr(new DestinationHandle(DestinationContext::Proxy::create(co
ntext2, tracker))); | 424 *dest2 = adoptPtr(new DestinationHandle(DestinationContext::Proxy::create(co
ntext2, tracker))); |
| 423 } | 425 } |
| 424 | 426 |
| 427 void DataConsumerTee::create(ExecutionContext* executionContext, PassOwnPtr<Fetc
hDataConsumerHandle> src, OwnPtr<FetchDataConsumerHandle>* dest1, OwnPtr<FetchDa
taConsumerHandle>* dest2) |
| 428 { |
| 429 RefPtr<BlobDataHandle> blobDataHandle = src->obtainReader(nullptr)->drainAsB
lobDataHandle(FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize); |
| 430 if (blobDataHandle) { |
| 431 *dest1 = FetchBlobDataConsumerHandle::create(executionContext, blobDataH
andle); |
| 432 *dest2 = FetchBlobDataConsumerHandle::create(executionContext, blobDataH
andle); |
| 433 return; |
| 434 } |
| 435 |
| 436 OwnPtr<WebDataConsumerHandle> webDest1, webDest2; |
| 437 DataConsumerTee::create(executionContext, static_cast<PassOwnPtr<WebDataCons
umerHandle>>(src), &webDest1, &webDest2); |
| 438 *dest1 = createFetchDataConsumerHandleFromWebHandle(webDest1.release()); |
| 439 *dest2 = createFetchDataConsumerHandleFromWebHandle(webDest2.release()); |
| 440 return; |
| 441 } |
| 442 |
| 425 } // namespace blink | 443 } // namespace blink |
| OLD | NEW |