OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 569 |
570 std::unique_ptr<Function<int(CountCopy)>> bound2 = bind(takeCountCopyAsValue
); | 570 std::unique_ptr<Function<int(CountCopy)>> bound2 = bind(takeCountCopyAsValue
); |
571 EXPECT_EQ(3, (*bound2)(lvalue)); // At Function::operator(), at Callback::Ru
n() and at the destination function. | 571 EXPECT_EQ(3, (*bound2)(lvalue)); // At Function::operator(), at Callback::Ru
n() and at the destination function. |
572 EXPECT_LE((*bound2)(CountCopy()), 2); // Compiler is allowed to optimize one
copy away if the argument is rvalue. | 572 EXPECT_LE((*bound2)(CountCopy()), 2); // Compiler is allowed to optimize one
copy away if the argument is rvalue. |
573 } | 573 } |
574 | 574 |
575 TEST(FunctionalTest, WeakPtr) | 575 TEST(FunctionalTest, WeakPtr) |
576 { | 576 { |
577 HasWeakPtrSupport obj; | 577 HasWeakPtrSupport obj; |
578 int counter = 0; | 578 int counter = 0; |
579 std::unique_ptr<WTF::SameThreadClosure> bound = WTF::bind(&HasWeakPtrSupport
::increment, obj.createWeakPtr(), WTF::unretained(&counter)); | 579 std::unique_ptr<WTF::Closure> bound = WTF::bind(&HasWeakPtrSupport::incremen
t, obj.createWeakPtr(), WTF::unretained(&counter)); |
580 | 580 |
581 (*bound)(); | 581 (*bound)(); |
582 EXPECT_EQ(1, counter); | 582 EXPECT_EQ(1, counter); |
583 | 583 |
584 obj.revokeAll(); | 584 obj.revokeAll(); |
585 (*bound)(); | 585 (*bound)(); |
586 EXPECT_EQ(1, counter); | 586 EXPECT_EQ(1, counter); |
587 } | 587 } |
588 | 588 |
589 } // anonymous namespace | 589 } // anonymous namespace |
590 | 590 |
591 } // namespace WTF | 591 } // namespace WTF |
OLD | NEW |