Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/DataConsumerTee.cpp

Issue 2103823002: Disallow raw pointers in CrossThreadCopier/threadSafeBind() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug fix. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void notify() 178 void notify()
179 { 179 {
180 { 180 {
181 MutexLocker locker(m_mutex); 181 MutexLocker locker(m_mutex);
182 if (!m_client) { 182 if (!m_client) {
183 // No client is registered. 183 // No client is registered.
184 return; 184 return;
185 } 185 }
186 ASSERT(m_readerThread); 186 ASSERT(m_readerThread);
187 if (!m_readerThread->isCurrentThread()) { 187 if (!m_readerThread->isCurrentThread()) {
188 m_readerThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, th readSafeBind(&DestinationContext::notify, this)); 188 m_readerThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, th readSafeBind(&DestinationContext::notify, wrapPassRefPtr(this)));
189 return; 189 return;
190 } 190 }
191 } 191 }
192 // The reading thread is the current thread. 192 // The reading thread is the current thread.
193 if (m_client) 193 if (m_client)
194 m_client->didGetReadable(); 194 m_client->didGetReadable();
195 } 195 }
196 196
197 Mutex& mutex() { return m_mutex; } 197 Mutex& mutex() { return m_mutex; }
198 198
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 public: 265 public:
266 DestinationReader(PassRefPtr<DestinationContext::Proxy> contextProxy, WebDat aConsumerHandle::Client* client) 266 DestinationReader(PassRefPtr<DestinationContext::Proxy> contextProxy, WebDat aConsumerHandle::Client* client)
267 : m_contextProxy(contextProxy) 267 : m_contextProxy(contextProxy)
268 { 268 {
269 MutexLocker locker(context()->mutex()); 269 MutexLocker locker(context()->mutex());
270 context()->attachReader(client); 270 context()->attachReader(client);
271 if (client) { 271 if (client) {
272 // We need to use threadSafeBind here to retain the context. Note 272 // We need to use threadSafeBind here to retain the context. Note
273 // |context()| return value is of type DestinationContext*, not 273 // |context()| return value is of type DestinationContext*, not
274 // PassRefPtr<DestinationContext>. 274 // PassRefPtr<DestinationContext>.
275 Platform::current()->currentThread()->getWebTaskRunner()->postTask(B LINK_FROM_HERE, threadSafeBind(&DestinationContext::notify, context())); 275 Platform::current()->currentThread()->getWebTaskRunner()->postTask(B LINK_FROM_HERE, threadSafeBind(&DestinationContext::notify, wrapPassRefPtr(conte xt())));
276 } 276 }
277 } 277 }
278 ~DestinationReader() override 278 ~DestinationReader() override
279 { 279 {
280 MutexLocker locker(context()->mutex()); 280 MutexLocker locker(context()->mutex());
281 context()->detachReader(); 281 context()->detachReader();
282 } 282 }
283 283
284 Result beginRead(const void** buffer, Flags, size_t* available) override 284 Result beginRead(const void** buffer, Flags, size_t* available) override
285 { 285 {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 426 }
427 427
428 std::unique_ptr<WebDataConsumerHandle> webDest1, webDest2; 428 std::unique_ptr<WebDataConsumerHandle> webDest1, webDest2;
429 DataConsumerTee::create(executionContext, static_cast<std::unique_ptr<WebDat aConsumerHandle>>(std::move(src)), &webDest1, &webDest2); 429 DataConsumerTee::create(executionContext, static_cast<std::unique_ptr<WebDat aConsumerHandle>>(std::move(src)), &webDest1, &webDest2);
430 *dest1 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest1)); 430 *dest1 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest1));
431 *dest2 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest2)); 431 *dest2 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest2));
432 return; 432 return;
433 } 433 }
434 434
435 } // namespace blink 435 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698