Lines Matching full:target
53 struct Target : public TargetBase, public SupportsWeakPtr<Target> { struct
54 virtual ~Target() = default;
57 struct DerivedTarget : public Target {};
59 // A class inheriting from Target and defining a nested type called 'Base'.
61 struct DerivedTargetWithNestedBase : public Target {
70 // A class inheriting from Target where Target is not the first base, and where
72 // Target base is not positioned at the beginning of
75 public Target {};
78 WeakPtr<Target> target; member
80 struct TargetWithFactory : public Target {
82 WeakPtrFactory<Target> factory;
93 void CreateArrowFromTarget(Arrow** arrow, Target* target) { in CreateArrowFromTarget() argument
98 arrow, target, &completion)); in CreateArrowFromTarget()
111 void DeleteTarget(Target* object) { in DeleteTarget()
147 Target* DeRef(const Arrow* arrow) { in DeRef()
150 Target* result = nullptr; in DeRef()
168 Target* target, in DoCreateArrowFromTarget() argument
171 (*arrow)->target = target->AsWeakPtr(); in DoCreateArrowFromTarget()
176 Target** result, in DoDeRef()
178 *result = arrow->target.get(); in DoDeRef()
182 static void DoDeleteTarget(Target* object, WaitableEvent* completion) { in DoDeleteTarget()
199 WeakPtr<TargetBase> b = object->target; in DoCopyAndAssignArrowBase()
202 c = object->target; in DoCopyAndAssignArrowBase()
302 Target target; in TEST() local
303 WeakPtr<Target> ptr = target.AsWeakPtr(); in TEST()
304 EXPECT_EQ(&target, ptr.get()); in TEST()
308 DerivedTarget target; in TEST() local
309 WeakPtr<DerivedTarget> ptr = AsWeakPtr(&target); in TEST()
310 EXPECT_EQ(&target, ptr.get()); in TEST()
314 DerivedTargetWithNestedBase target; in TEST() local
315 WeakPtr<DerivedTargetWithNestedBase> ptr = AsWeakPtr(&target); in TEST()
316 EXPECT_EQ(&target, ptr.get()); in TEST()
321 Target& b = d; in TEST()
323 const WeakPtr<Target> pb = AsWeakPtr(&b); in TEST()
408 std::unique_ptr<Target> target(OffThreadObjectCreator<Target>::NewObject()); in TEST() local
409 WeakPtr<Target> weak_ptr = target->AsWeakPtr(); in TEST()
410 EXPECT_EQ(target.get(), weak_ptr.get()); in TEST()
418 Target target; in TEST() local
419 arrow->target = target.AsWeakPtr(); in TEST()
420 EXPECT_EQ(&target, arrow->target.get()); in TEST()
430 Target* target = new Target(); in TEST() local
432 WeakPtr<Target> weak_ptr = target->AsWeakPtr(); in TEST()
439 background.CreateArrowFromTarget(&arrow, target); in TEST()
440 EXPECT_EQ(background.DeRef(arrow), target); in TEST()
446 arrow.target = target->AsWeakPtr(); in TEST()
449 EXPECT_EQ(target, background.DeRef(&arrow)); in TEST()
452 // Target can only be deleted on background thread. in TEST()
453 background.DeleteTarget(target); in TEST()
463 Target target; in TEST() local
465 background.CreateArrowFromTarget(&arrow, &target); in TEST()
468 EXPECT_EQ(&target, background.DeRef(arrow)); in TEST()
471 arrow->target.reset(); in TEST()
474 arrow->target = target.AsWeakPtr(); in TEST()
477 EXPECT_EQ(&target, arrow->target.get()); in TEST()
479 // And the main thread can now delete the target. in TEST()
490 std::unique_ptr<TargetWithFactory> target(new TargetWithFactory); in TEST() local
493 arrow.target = target->factory.GetWeakPtr(); in TEST()
494 EXPECT_EQ(target.get(), arrow.target.get()); in TEST()
496 target->factory.InvalidateWeakPtrs(); in TEST()
497 EXPECT_EQ(nullptr, arrow.target.get()); in TEST()
499 arrow.target = target->factory.GetWeakPtr(); in TEST()
501 EXPECT_EQ(target.get(), background.DeRef(&arrow)); in TEST()
503 // And the background thread can now delete the target. in TEST()
504 background.DeleteTarget(target.release()); in TEST()
516 Target target; in TEST() local
518 arrow.target = target.AsWeakPtr(); in TEST()
522 EXPECT_EQ(arrow_copy->target.get(), &target); in TEST()
534 Target target; in TEST() local
538 arrow.target = target.AsWeakPtr(); in TEST()
541 EXPECT_EQ(arrow_copy->target.get(), &target); in TEST()
555 Target target; in TEST() local
557 arrow.target = target.AsWeakPtr(); in TEST()
560 EXPECT_EQ(nullptr, arrow_copy->target.get()); in TEST()
565 // Main thread creates a Target object. in TEST()
566 Target target; in TEST() local
567 // Main thread creates an arrow referencing the Target. in TEST()
569 arrow->target = target.AsWeakPtr(); in TEST()
579 // Main thread creates a Target object. in TEST()
580 Target target; in TEST() local
581 // Main thread creates an arrow referencing the Target. in TEST()
583 arrow->target = target.AsWeakPtr(); in TEST()
593 // Main thread creates a Target object. in TEST()
594 Target target; in TEST() local
595 // Main thread creates an arrow referencing the Target. in TEST()
597 arrow->target = target.AsWeakPtr(); in TEST()
613 // Main thread creates a Target object. in TEST()
614 Target target; in TEST() local
615 // Main thread creates an arrow referencing the Target. in TEST()
617 arrow.target = target.AsWeakPtr(); in TEST()
624 EXPECT_EQ(arrow.target.get(), arrow_copy->target.get()); in TEST()
638 // Main thread creates a Target object. in TEST()
639 Target target; in TEST() local
641 // Main thread creates an arrow referencing the Target (so target's in TEST()
644 arrow.target = target.AsWeakPtr(); in TEST()
645 arrow.target.get(); in TEST()
647 // Background thread tries to deref target, which violates thread ownership. in TEST()
658 std::unique_ptr<Target> target(new Target()); in TEST() local
660 // Main thread creates an arrow referencing the Target. in TEST()
662 arrow.target = target->AsWeakPtr(); in TEST()
664 // Background thread tries to deref target, binding it to the thread. in TEST()
669 // Main thread deletes Target, violating thread binding. in TEST()
670 ASSERT_DCHECK_DEATH(target.reset()); in TEST()
672 // |target.reset()| died so |target| still holds the object, so we in TEST()
674 background.DeleteTarget(target.release()); in TEST()
682 std::unique_ptr<Target> target(new Target()); in TEST() local
684 // Main thread creates an arrow referencing the Target, and references it, so in TEST()
687 arrow.target = target->AsWeakPtr(); in TEST()
688 arrow.target.get(); in TEST()
690 // Background thread tries to delete target, volating thread binding. in TEST()
693 ASSERT_DCHECK_DEATH(background.DeleteTarget(target.release())); in TEST()
701 std::unique_ptr<Target> target(new Target()); in TEST() local
703 // Main thread creates an arrow referencing the Target. in TEST()
705 arrow.target = target->AsWeakPtr(); in TEST()
707 // Background thread tries to delete target, binding the object to the thread. in TEST()
710 background.DeleteTarget(target.release()); in TEST()
712 // Main thread attempts to dereference the target, violating thread binding. in TEST()
713 ASSERT_DCHECK_DEATH(arrow.target.get()); in TEST()