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

Unified Diff: base/memory/weak_ptr_unittest.cc

Issue 19522006: GLInProcessContext: support async flushes and dedicated GPU thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linker error w/android component build Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/weak_ptr.h ('k') | gpu/command_buffer/client/gl_in_process_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/weak_ptr_unittest.cc
diff --git a/base/memory/weak_ptr_unittest.cc b/base/memory/weak_ptr_unittest.cc
index be3b6dbf6d1e6104435bc8a29e1cbda42621e946..799fab0c93a7da09ab1f6a60caf4c200e0165ae2 100644
--- a/base/memory/weak_ptr_unittest.cc
+++ b/base/memory/weak_ptr_unittest.cc
@@ -336,21 +336,6 @@ TEST(WeakPtrTest, MoveOwnershipImplicitly) {
background.DeleteArrow(arrow);
}
-TEST(WeakPtrTest, MoveOwnershipExplicitlyObjectNotReferenced) {
- // Case 1: The target is not bound to any thread yet. So calling
- // DetachFromThread() is a no-op.
- Target target;
- target.DetachFromThreadHack();
-
- // Case 2: The target is bound to main thread but no WeakPtr is pointing to
- // it. In this case, it will be re-bound to any thread trying to get a
- // WeakPtr pointing to it. So detach function call is again no-op.
- {
- WeakPtr<Target> weak_ptr = target.AsWeakPtr();
- }
- target.DetachFromThreadHack();
-}
-
TEST(WeakPtrTest, MoveOwnershipExplicitly) {
BackgroundThread background;
background.Start();
@@ -358,12 +343,15 @@ TEST(WeakPtrTest, MoveOwnershipExplicitly) {
Arrow* arrow;
{
Target target;
- // Background thread creates WeakPtr(and implicitly owns the object).
+ // Background thread creates WeakPtr.
background.CreateArrowFromTarget(&arrow, &target);
+
+ // Bind to background thread.
EXPECT_EQ(&target, background.DeRef(arrow));
- // Detach from background thread.
- target.DetachFromThreadHack();
+ // Invalidating the only weak pointer unbinds it from the background thread.
+ arrow->target.reset();
Wez 2013/07/31 22:46:43 This should crash, since you're invalidating from
+ arrow->target = target.AsWeakPtr();
// Re-bind to main thread.
EXPECT_EQ(&target, arrow->target.get());
« no previous file with comments | « base/memory/weak_ptr.h ('k') | gpu/command_buffer/client/gl_in_process_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698