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" | 10 #include "modules/fetch/DataConsumerHandleUtil.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void notify() | 177 void notify() |
178 { | 178 { |
179 { | 179 { |
180 MutexLocker locker(m_mutex); | 180 MutexLocker locker(m_mutex); |
181 if (!m_client) { | 181 if (!m_client) { |
182 // No client is registered. | 182 // No client is registered. |
183 return; | 183 return; |
184 } | 184 } |
185 ASSERT(m_readerThread); | 185 ASSERT(m_readerThread); |
186 if (!m_readerThread->isCurrentThread()) { | 186 if (!m_readerThread->isCurrentThread()) { |
187 m_readerThread->postTask(FROM_HERE, new Task(threadSafeBind(&Des
tinationContext::notify, this))); | 187 m_readerThread->taskRunner()->postTask(FROM_HERE, new Task(threa
dSafeBind(&DestinationContext::notify, this))); |
188 return; | 188 return; |
189 } | 189 } |
190 } | 190 } |
191 // The reading thread is the current thread. | 191 // The reading thread is the current thread. |
192 if (m_client) | 192 if (m_client) |
193 m_client->didGetReadable(); | 193 m_client->didGetReadable(); |
194 } | 194 } |
195 | 195 |
196 Mutex& mutex() { return m_mutex; } | 196 Mutex& mutex() { return m_mutex; } |
197 | 197 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 public: | 264 public: |
265 DestinationReader(PassRefPtr<DestinationContext::Proxy> contextProxy, WebDat
aConsumerHandle::Client* client) | 265 DestinationReader(PassRefPtr<DestinationContext::Proxy> contextProxy, WebDat
aConsumerHandle::Client* client) |
266 : m_contextProxy(contextProxy) | 266 : m_contextProxy(contextProxy) |
267 { | 267 { |
268 MutexLocker(context()->mutex()); | 268 MutexLocker(context()->mutex()); |
269 context()->attachReader(client); | 269 context()->attachReader(client); |
270 if (client) { | 270 if (client) { |
271 // We need to use threadSafeBind here to retain the context. Note | 271 // We need to use threadSafeBind here to retain the context. Note |
272 // |context()| return value is of type DestinationContext*, not | 272 // |context()| return value is of type DestinationContext*, not |
273 // PassRefPtr<DestinationContext>. | 273 // PassRefPtr<DestinationContext>. |
274 Platform::current()->currentThread()->postTask(FROM_HERE, new Task(t
hreadSafeBind(&DestinationContext::notify, context()))); | 274 Platform::current()->currentThread()->taskRunner()->postTask(FROM_HE
RE, new Task(threadSafeBind(&DestinationContext::notify, context()))); |
275 } | 275 } |
276 } | 276 } |
277 ~DestinationReader() override | 277 ~DestinationReader() override |
278 { | 278 { |
279 MutexLocker(context()->mutex()); | 279 MutexLocker(context()->mutex()); |
280 context()->detachReader(); | 280 context()->detachReader(); |
281 } | 281 } |
282 | 282 |
283 Result read(void* buffer, size_t size, Flags, size_t* readSize) override | 283 Result read(void* buffer, size_t size, Flags, size_t* readSize) override |
284 { | 284 { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 440 } |
441 | 441 |
442 OwnPtr<WebDataConsumerHandle> webDest1, webDest2; | 442 OwnPtr<WebDataConsumerHandle> webDest1, webDest2; |
443 DataConsumerTee::create(executionContext, static_cast<PassOwnPtr<WebDataCons
umerHandle>>(src), &webDest1, &webDest2); | 443 DataConsumerTee::create(executionContext, static_cast<PassOwnPtr<WebDataCons
umerHandle>>(src), &webDest1, &webDest2); |
444 *dest1 = createFetchDataConsumerHandleFromWebHandle(webDest1.release()); | 444 *dest1 = createFetchDataConsumerHandleFromWebHandle(webDest1.release()); |
445 *dest2 = createFetchDataConsumerHandleFromWebHandle(webDest2.release()); | 445 *dest2 = createFetchDataConsumerHandleFromWebHandle(webDest2.release()); |
446 return; | 446 return; |
447 } | 447 } |
448 | 448 |
449 } // namespace blink | 449 } // namespace blink |
OLD | NEW |