| 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/CompositeDataConsumerHandle.h" | 5 #include "modules/fetch/CompositeDataConsumerHandle.h" |
| 6 | 6 |
| 7 #include "platform/Task.h" | |
| 8 #include "platform/ThreadSafeFunctional.h" | 7 #include "platform/ThreadSafeFunctional.h" |
| 9 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
| 9 #include "public/platform/WebTaskRunner.h" |
| 10 #include "public/platform/WebThread.h" | 10 #include "public/platform/WebThread.h" |
| 11 #include "public/platform/WebTraceLocation.h" | 11 #include "public/platform/WebTraceLocation.h" |
| 12 #include "wtf/Locker.h" | 12 #include "wtf/Locker.h" |
| 13 #include "wtf/ThreadSafeRefCounted.h" | 13 #include "wtf/ThreadSafeRefCounted.h" |
| 14 #include "wtf/ThreadingPrimitives.h" | 14 #include "wtf/ThreadingPrimitives.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 using Result = WebDataConsumerHandle::Result; | 18 using Result = WebDataConsumerHandle::Result; |
| 19 | 19 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // We are waiting for the two-phase read completion. | 133 // We are waiting for the two-phase read completion. |
| 134 m_isUpdateWaitingForEndRead = true; | 134 m_isUpdateWaitingForEndRead = true; |
| 135 return; | 135 return; |
| 136 } | 136 } |
| 137 // Unregister the old one, then register the new one. | 137 // Unregister the old one, then register the new one. |
| 138 m_reader = nullptr; | 138 m_reader = nullptr; |
| 139 m_reader = m_handle->obtainReader(m_client); | 139 m_reader = m_handle->obtainReader(m_client); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 ++m_token; | 142 ++m_token; |
| 143 m_readerThread->taskRunner()->postTask(BLINK_FROM_HERE, new Task(threadS
afeBind(&Context::updateReader, this, m_token))); | 143 m_readerThread->taskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&
Context::updateReader, this, m_token)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 OwnPtr<Reader> m_reader; | 146 OwnPtr<Reader> m_reader; |
| 147 OwnPtr<WebDataConsumerHandle> m_handle; | 147 OwnPtr<WebDataConsumerHandle> m_handle; |
| 148 // Note: Holding a WebThread raw pointer is not generally safe, but we can | 148 // Note: Holding a WebThread raw pointer is not generally safe, but we can |
| 149 // do that in this case because: | 149 // do that in this case because: |
| 150 // 1. Destructing a ReaderImpl when the bound thread ends is a user's | 150 // 1. Destructing a ReaderImpl when the bound thread ends is a user's |
| 151 // responsibility. | 151 // responsibility. |
| 152 // 2. |m_readerThread| will never be used after the associated reader is | 152 // 2. |m_readerThread| will never be used after the associated reader is |
| 153 // detached. | 153 // detached. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 CompositeDataConsumerHandle::~CompositeDataConsumerHandle() { } | 208 CompositeDataConsumerHandle::~CompositeDataConsumerHandle() { } |
| 209 | 209 |
| 210 WebDataConsumerHandle::Reader* CompositeDataConsumerHandle::obtainReaderInternal
(Client* client) | 210 WebDataConsumerHandle::Reader* CompositeDataConsumerHandle::obtainReaderInternal
(Client* client) |
| 211 { | 211 { |
| 212 return m_context->obtainReader(client).leakPtr(); | 212 return m_context->obtainReader(client).leakPtr(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace blink | 215 } // namespace blink |
| OLD | NEW |