OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |