| 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 5522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5533 // Setting an object created on the worker thread to a Member allocated on | 5533 // Setting an object created on the worker thread to a Member allocated on |
| 5534 // the main thread is not allowed. | 5534 // the main thread is not allowed. |
| 5535 wrapper_ = IntWrapper::Create(42); | 5535 wrapper_ = IntWrapper::Create(42); |
| 5536 | 5536 |
| 5537 WakeMainThread(); | 5537 WakeMainThread(); |
| 5538 ThreadState::DetachCurrentThread(); | 5538 ThreadState::DetachCurrentThread(); |
| 5539 } | 5539 } |
| 5540 }; | 5540 }; |
| 5541 | 5541 |
| 5542 #if DCHECK_IS_ON() | 5542 #if DCHECK_IS_ON() |
| 5543 // TODO(keishi) This test is flaky on mac_chromium_rel_ng bot. |
| 5544 // crbug.com/709069 |
| 5545 #if !OS(MACOSX) |
| 5543 TEST(HeapDeathTest, MemberSameThreadCheck) { | 5546 TEST(HeapDeathTest, MemberSameThreadCheck) { |
| 5544 EXPECT_DEATH(MemberSameThreadCheckTester().Test(), ""); | 5547 EXPECT_DEATH(MemberSameThreadCheckTester().Test(), ""); |
| 5545 } | 5548 } |
| 5546 #endif | 5549 #endif |
| 5550 #endif |
| 5547 | 5551 |
| 5548 class PersistentSameThreadCheckTester { | 5552 class PersistentSameThreadCheckTester { |
| 5549 public: | 5553 public: |
| 5550 void Test() { | 5554 void Test() { |
| 5551 IntWrapper::destructor_calls_ = 0; | 5555 IntWrapper::destructor_calls_ = 0; |
| 5552 | 5556 |
| 5553 MutexLocker locker(MainThreadMutex()); | 5557 MutexLocker locker(MainThreadMutex()); |
| 5554 std::unique_ptr<WebThread> worker_thread = WTF::WrapUnique( | 5558 std::unique_ptr<WebThread> worker_thread = WTF::WrapUnique( |
| 5555 Platform::Current()->CreateThread("Test Worker Thread")); | 5559 Platform::Current()->CreateThread("Test Worker Thread")); |
| 5556 worker_thread->GetWebTaskRunner()->PostTask( | 5560 worker_thread->GetWebTaskRunner()->PostTask( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5572 // Setting an object created on the worker thread to a Persistent allocated | 5576 // Setting an object created on the worker thread to a Persistent allocated |
| 5573 // on the main thread is not allowed. | 5577 // on the main thread is not allowed. |
| 5574 wrapper_ = IntWrapper::Create(42); | 5578 wrapper_ = IntWrapper::Create(42); |
| 5575 | 5579 |
| 5576 WakeMainThread(); | 5580 WakeMainThread(); |
| 5577 ThreadState::DetachCurrentThread(); | 5581 ThreadState::DetachCurrentThread(); |
| 5578 } | 5582 } |
| 5579 }; | 5583 }; |
| 5580 | 5584 |
| 5581 #if DCHECK_IS_ON() | 5585 #if DCHECK_IS_ON() |
| 5586 // TODO(keishi) This test is flaky on mac_chromium_rel_ng bot. |
| 5587 // crbug.com/709069 |
| 5588 #if !OS(MACOSX) |
| 5582 TEST(HeapDeathTest, PersistentSameThreadCheck) { | 5589 TEST(HeapDeathTest, PersistentSameThreadCheck) { |
| 5583 EXPECT_DEATH(PersistentSameThreadCheckTester().Test(), ""); | 5590 EXPECT_DEATH(PersistentSameThreadCheckTester().Test(), ""); |
| 5584 } | 5591 } |
| 5585 #endif | 5592 #endif |
| 5593 #endif |
| 5586 | 5594 |
| 5587 class MarkingSameThreadCheckTester { | 5595 class MarkingSameThreadCheckTester { |
| 5588 public: | 5596 public: |
| 5589 void Test() { | 5597 void Test() { |
| 5590 IntWrapper::destructor_calls_ = 0; | 5598 IntWrapper::destructor_calls_ = 0; |
| 5591 | 5599 |
| 5592 MutexLocker locker(MainThreadMutex()); | 5600 MutexLocker locker(MainThreadMutex()); |
| 5593 std::unique_ptr<WebThread> worker_thread = WTF::WrapUnique( | 5601 std::unique_ptr<WebThread> worker_thread = WTF::WrapUnique( |
| 5594 Platform::Current()->CreateThread("Test Worker Thread")); | 5602 Platform::Current()->CreateThread("Test Worker Thread")); |
| 5595 Persistent<MainThreadObject> main_thread_object = new MainThreadObject(); | 5603 Persistent<MainThreadObject> main_thread_object = new MainThreadObject(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5622 // Adding a reference to an object created on the worker thread to a | 5630 // Adding a reference to an object created on the worker thread to a |
| 5623 // HeapHashMap created on the main thread is not allowed. | 5631 // HeapHashMap created on the main thread is not allowed. |
| 5624 main_thread_object->AddToSet(IntWrapper::Create(42)); | 5632 main_thread_object->AddToSet(IntWrapper::Create(42)); |
| 5625 | 5633 |
| 5626 WakeMainThread(); | 5634 WakeMainThread(); |
| 5627 ThreadState::DetachCurrentThread(); | 5635 ThreadState::DetachCurrentThread(); |
| 5628 } | 5636 } |
| 5629 }; | 5637 }; |
| 5630 | 5638 |
| 5631 #if DCHECK_IS_ON() | 5639 #if DCHECK_IS_ON() |
| 5640 // TODO(keishi) This test is flaky on mac_chromium_rel_ng bot. |
| 5641 // crbug.com/709069 |
| 5642 #if !OS(MACOSX) |
| 5632 TEST(HeapDeathTest, MarkingSameThreadCheck) { | 5643 TEST(HeapDeathTest, MarkingSameThreadCheck) { |
| 5633 // This will crash during marking, at the DCHECK in Visitor::markHeader() or | 5644 // This will crash during marking, at the DCHECK in Visitor::markHeader() or |
| 5634 // earlier. | 5645 // earlier. |
| 5635 EXPECT_DEATH(MarkingSameThreadCheckTester().Test(), ""); | 5646 EXPECT_DEATH(MarkingSameThreadCheckTester().Test(), ""); |
| 5636 } | 5647 } |
| 5637 #endif | 5648 #endif |
| 5649 #endif |
| 5638 | 5650 |
| 5639 static bool AllocateAndReturnBool() { | 5651 static bool AllocateAndReturnBool() { |
| 5640 ConservativelyCollectGarbage(); | 5652 ConservativelyCollectGarbage(); |
| 5641 return true; | 5653 return true; |
| 5642 } | 5654 } |
| 5643 | 5655 |
| 5644 static bool CheckGCForbidden() { | 5656 static bool CheckGCForbidden() { |
| 5645 ASSERT(ThreadState::Current()->IsGCForbidden()); | 5657 ASSERT(ThreadState::Current()->IsGCForbidden()); |
| 5646 return true; | 5658 return true; |
| 5647 } | 5659 } |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6667 map.insert(key, IntWrapper::Create(i)); | 6679 map.insert(key, IntWrapper::Create(i)); |
| 6668 } | 6680 } |
| 6669 | 6681 |
| 6670 EXPECT_FALSE(string.Impl()->HasOneRef()); | 6682 EXPECT_FALSE(string.Impl()->HasOneRef()); |
| 6671 map.Clear(); | 6683 map.Clear(); |
| 6672 | 6684 |
| 6673 EXPECT_TRUE(string.Impl()->HasOneRef()); | 6685 EXPECT_TRUE(string.Impl()->HasOneRef()); |
| 6674 } | 6686 } |
| 6675 | 6687 |
| 6676 } // namespace blink | 6688 } // namespace blink |
| OLD | NEW |