| 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/DataConsumerTee.h" | 5 #include "modules/fetch/DataConsumerTee.h" |
| 6 | 6 |
| 7 #include "core/dom/ActiveDOMObject.h" | 7 #include "core/dom/ActiveDOMObject.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "modules/fetch/DataConsumerHandleUtil.h" | 9 #include "modules/fetch/DataConsumerHandleUtil.h" |
| 10 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | 10 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 static PassRefPtr<DestinationContext> create() { return adoptRef(new Destina
tionContext()); } | 143 static PassRefPtr<DestinationContext> create() { return adoptRef(new Destina
tionContext()); } |
| 144 | 144 |
| 145 void enqueue(const char* buffer, size_t size) | 145 void enqueue(const char* buffer, size_t size) |
| 146 { | 146 { |
| 147 bool needsNotification = false; | 147 bool needsNotification = false; |
| 148 { | 148 { |
| 149 MutexLocker locker(m_mutex); | 149 MutexLocker locker(m_mutex); |
| 150 needsNotification = m_queue.isEmpty(); | 150 needsNotification = m_queue.isEmpty(); |
| 151 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>); | 151 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>); |
| 152 data->append(buffer, size); | 152 data->append(buffer, size); |
| 153 m_queue.append(data.release()); | 153 m_queue.append(std::move(data)); |
| 154 } | 154 } |
| 155 if (needsNotification) | 155 if (needsNotification) |
| 156 notify(); | 156 notify(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void setResult(Result r) | 159 void setResult(Result r) |
| 160 { | 160 { |
| 161 ASSERT(r != WebDataConsumerHandle::Ok); | 161 ASSERT(r != WebDataConsumerHandle::Ok); |
| 162 ASSERT(r != WebDataConsumerHandle::ShouldWait); | 162 ASSERT(r != WebDataConsumerHandle::ShouldWait); |
| 163 { | 163 { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 { | 418 { |
| 419 RefPtr<BlobDataHandle> blobDataHandle = src->obtainReader(nullptr)->drainAsB
lobDataHandle(FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize); | 419 RefPtr<BlobDataHandle> blobDataHandle = src->obtainReader(nullptr)->drainAsB
lobDataHandle(FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize); |
| 420 if (blobDataHandle) { | 420 if (blobDataHandle) { |
| 421 *dest1 = FetchBlobDataConsumerHandle::create(executionContext, blobDataH
andle); | 421 *dest1 = FetchBlobDataConsumerHandle::create(executionContext, blobDataH
andle); |
| 422 *dest2 = FetchBlobDataConsumerHandle::create(executionContext, blobDataH
andle); | 422 *dest2 = FetchBlobDataConsumerHandle::create(executionContext, blobDataH
andle); |
| 423 return; | 423 return; |
| 424 } | 424 } |
| 425 | 425 |
| 426 OwnPtr<WebDataConsumerHandle> webDest1, webDest2; | 426 OwnPtr<WebDataConsumerHandle> webDest1, webDest2; |
| 427 DataConsumerTee::create(executionContext, static_cast<PassOwnPtr<WebDataCons
umerHandle>>(std::move(src)), &webDest1, &webDest2); | 427 DataConsumerTee::create(executionContext, static_cast<PassOwnPtr<WebDataCons
umerHandle>>(std::move(src)), &webDest1, &webDest2); |
| 428 *dest1 = createFetchDataConsumerHandleFromWebHandle(webDest1.release()); | 428 *dest1 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest1)); |
| 429 *dest2 = createFetchDataConsumerHandleFromWebHandle(webDest2.release()); | 429 *dest2 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest2)); |
| 430 return; | 430 return; |
| 431 } | 431 } |
| 432 | 432 |
| 433 } // namespace blink | 433 } // namespace blink |
| OLD | NEW |