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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.h

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 #ifndef DataConsumerHandleTestUtil_h 5 #ifndef DataConsumerHandleTestUtil_h
6 #define DataConsumerHandleTestUtil_h 6 #define DataConsumerHandleTestUtil_h
7 7
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/testing/NullExecutionContext.h" 9 #include "core/testing/NullExecutionContext.h"
10 #include "gin/public/isolate_holder.h" 10 #include "gin/public/isolate_holder.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 public: 249 public:
250 using Self = ThreadingHandleNotificationTest; 250 using Self = ThreadingHandleNotificationTest;
251 static PassRefPtr<Self> create() { return adoptRef(new Self); } 251 static PassRefPtr<Self> create() { return adoptRef(new Self); }
252 252
253 void run(std::unique_ptr<WebDataConsumerHandle> handle) 253 void run(std::unique_ptr<WebDataConsumerHandle> handle)
254 { 254 {
255 ThreadHolder holder(this); 255 ThreadHolder holder(this);
256 m_waitableEvent = wrapUnique(new WaitableEvent()); 256 m_waitableEvent = wrapUnique(new WaitableEvent());
257 m_handle = std::move(handle); 257 m_handle = std::move(handle);
258 258
259 postTaskToReadingThreadAndWait(BLINK_FROM_HERE, threadSafeBind(&Self ::obtainReader, this)); 259 postTaskToReadingThreadAndWait(BLINK_FROM_HERE, threadSafeBind(&Self ::obtainReader, wrapPassRefPtr(this)));
260 } 260 }
261 261
262 private: 262 private:
263 ThreadingHandleNotificationTest() = default; 263 ThreadingHandleNotificationTest() = default;
264 void obtainReader() 264 void obtainReader()
265 { 265 {
266 m_reader = m_handle->obtainReader(this); 266 m_reader = m_handle->obtainReader(this);
267 } 267 }
268 void didGetReadable() override 268 void didGetReadable() override
269 { 269 {
270 postTaskToReadingThread(BLINK_FROM_HERE, threadSafeBind(&Self::reset Reader, this)); 270 postTaskToReadingThread(BLINK_FROM_HERE, threadSafeBind(&Self::reset Reader, wrapPassRefPtr(this)));
271 postTaskToReadingThread(BLINK_FROM_HERE, threadSafeBind(&Self::signa lDone, this)); 271 postTaskToReadingThread(BLINK_FROM_HERE, threadSafeBind(&Self::signa lDone, wrapPassRefPtr(this)));
272 } 272 }
273 273
274 std::unique_ptr<WebDataConsumerHandle> m_handle; 274 std::unique_ptr<WebDataConsumerHandle> m_handle;
275 }; 275 };
276 276
277 class ThreadingHandleNoNotificationTest : public ThreadingTestBase, public W ebDataConsumerHandle::Client { 277 class ThreadingHandleNoNotificationTest : public ThreadingTestBase, public W ebDataConsumerHandle::Client {
278 public: 278 public:
279 using Self = ThreadingHandleNoNotificationTest; 279 using Self = ThreadingHandleNoNotificationTest;
280 static PassRefPtr<Self> create() { return adoptRef(new Self); } 280 static PassRefPtr<Self> create() { return adoptRef(new Self); }
281 281
282 void run(std::unique_ptr<WebDataConsumerHandle> handle) 282 void run(std::unique_ptr<WebDataConsumerHandle> handle)
283 { 283 {
284 ThreadHolder holder(this); 284 ThreadHolder holder(this);
285 m_waitableEvent = wrapUnique(new WaitableEvent()); 285 m_waitableEvent = wrapUnique(new WaitableEvent());
286 m_handle = std::move(handle); 286 m_handle = std::move(handle);
287 287
288 postTaskToReadingThreadAndWait(BLINK_FROM_HERE, threadSafeBind(&Self ::obtainReader, this)); 288 postTaskToReadingThreadAndWait(BLINK_FROM_HERE, threadSafeBind(&Self ::obtainReader, wrapPassRefPtr(this)));
289 } 289 }
290 290
291 private: 291 private:
292 ThreadingHandleNoNotificationTest() = default; 292 ThreadingHandleNoNotificationTest() = default;
293 void obtainReader() 293 void obtainReader()
294 { 294 {
295 m_reader = m_handle->obtainReader(this); 295 m_reader = m_handle->obtainReader(this);
296 m_reader = nullptr; 296 m_reader = nullptr;
297 postTaskToReadingThread(BLINK_FROM_HERE, threadSafeBind(&Self::signa lDone, this)); 297 postTaskToReadingThread(BLINK_FROM_HERE, threadSafeBind(&Self::signa lDone, wrapPassRefPtr(this)));
298 } 298 }
299 void didGetReadable() override 299 void didGetReadable() override
300 { 300 {
301 ASSERT_NOT_REACHED(); 301 ASSERT_NOT_REACHED();
302 } 302 }
303 303
304 std::unique_ptr<WebDataConsumerHandle> m_handle; 304 std::unique_ptr<WebDataConsumerHandle> m_handle;
305 }; 305 };
306 306
307 class MockFetchDataConsumerHandle : public FetchDataConsumerHandle { 307 class MockFetchDataConsumerHandle : public FetchDataConsumerHandle {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 std::unique_ptr<HandleReadResult> m_result; 533 std::unique_ptr<HandleReadResult> m_result;
534 bool m_isDone; 534 bool m_isDone;
535 535
536 std::unique_ptr<T> m_handleReader; 536 std::unique_ptr<T> m_handleReader;
537 }; 537 };
538 }; 538 };
539 539
540 } // namespace blink 540 } // namespace blink
541 541
542 #endif // DataConsumerHandleTestUtil_h 542 #endif // DataConsumerHandleTestUtil_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698