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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 1916923005: Disallow direct use of AllowCrossThreadAccessWrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_prep0
Patch Set: auto-Rebase Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/platform/CrossThreadCopier.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 6380 matching lines...) Expand 10 before | Expand all | Expand 10 after
6391 // Create an object in the worker thread, have a CrossThreadWeakPersistent p ointing to it on the main thread, 6391 // Create an object in the worker thread, have a CrossThreadWeakPersistent p ointing to it on the main thread,
6392 // clear the reference in the worker thread, run a GC in the worker thread, and see if the 6392 // clear the reference in the worker thread, run a GC in the worker thread, and see if the
6393 // CrossThreadWeakPersistent is cleared. 6393 // CrossThreadWeakPersistent is cleared.
6394 6394
6395 DestructorLockingObject::s_destructorCalls = 0; 6395 DestructorLockingObject::s_destructorCalls = 0;
6396 6396
6397 // Step 1: Initiate a worker thread, and wait for |object| to get allocated on the worker thread. 6397 // Step 1: Initiate a worker thread, and wait for |object| to get allocated on the worker thread.
6398 MutexLocker mainThreadMutexLocker(mainThreadMutex()); 6398 MutexLocker mainThreadMutexLocker(mainThreadMutex());
6399 OwnPtr<WebThread> workerThread = adoptPtr(Platform::current()->createThread( "Test Worker Thread")); 6399 OwnPtr<WebThread> workerThread = adoptPtr(Platform::current()->createThread( "Test Worker Thread"));
6400 DestructorLockingObject* object = nullptr; 6400 DestructorLockingObject* object = nullptr;
6401 workerThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(w orkerThreadMainForCrossThreadWeakPersistentTest, AllowCrossThreadAccessWrapper<D estructorLockingObject**>(&object))); 6401 workerThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(w orkerThreadMainForCrossThreadWeakPersistentTest, AllowCrossThreadAccess(&object) ));
6402 parkMainThread(); 6402 parkMainThread();
6403 6403
6404 // Step 3: Set up a CrossThreadWeakPersistent. 6404 // Step 3: Set up a CrossThreadWeakPersistent.
6405 ASSERT_TRUE(object); 6405 ASSERT_TRUE(object);
6406 CrossThreadWeakPersistent<DestructorLockingObject> crossThreadWeakPersistent (object); 6406 CrossThreadWeakPersistent<DestructorLockingObject> crossThreadWeakPersistent (object);
6407 object = nullptr; 6407 object = nullptr;
6408 { 6408 {
6409 SafePointAwareMutexLocker recursiveMutexLocker(recursiveMutex()); 6409 SafePointAwareMutexLocker recursiveMutexLocker(recursiveMutex());
6410 EXPECT_EQ(0, DestructorLockingObject::s_destructorCalls); 6410 EXPECT_EQ(0, DestructorLockingObject::s_destructorCalls);
6411 } 6411 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
6553 conservativelyCollectGarbage(); 6553 conservativelyCollectGarbage();
6554 EXPECT_EQ(wrapper, weakWrapper->value()); 6554 EXPECT_EQ(wrapper, weakWrapper->value());
6555 // Stub out any stack reference. 6555 // Stub out any stack reference.
6556 wrapper = nullptr; 6556 wrapper = nullptr;
6557 } 6557 }
6558 preciselyCollectGarbage(); 6558 preciselyCollectGarbage();
6559 EXPECT_EQ(nullptr, weakWrapper->value()); 6559 EXPECT_EQ(nullptr, weakWrapper->value());
6560 } 6560 }
6561 6561
6562 } // namespace blink 6562 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/CrossThreadCopier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698