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

Side by Side Diff: third_party/WebKit/Source/wtf/FunctionalTest.cpp

Issue 2110363002: Rename SameThreadClosure to Closure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_ExplicitWTFBind
Patch Set: Add WTF:: to Closure 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 /* 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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Functional.h ('k') | third_party/WebKit/public/platform/WebTaskRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698