| 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 | 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 DEFINE_INLINE_TRACE() { | 67 DEFINE_INLINE_TRACE() { |
| 68 visitor->Trace(observer_to_remove_on_destruct_); | 68 visitor->Trace(observer_to_remove_on_destruct_); |
| 69 LifecycleObserver::Trace(visitor); | 69 LifecycleObserver::Trace(visitor); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void Unobserve() { SetContext(nullptr); } | 72 void Unobserve() { SetContext(nullptr); } |
| 73 | 73 |
| 74 void SetObserverToRemoveAndDestroy( | 74 void SetObserverToRemoveAndDestroy( |
| 75 TestingObserver* observer_to_remove_on_destruct) { | 75 TestingObserver* observer_to_remove_on_destruct) { |
| 76 ASSERT(!observer_to_remove_on_destruct_); | 76 DCHECK(!observer_to_remove_on_destruct_); |
| 77 observer_to_remove_on_destruct_ = observer_to_remove_on_destruct; | 77 observer_to_remove_on_destruct_ = observer_to_remove_on_destruct; |
| 78 } | 78 } |
| 79 | 79 |
| 80 TestingObserver* InnerObserver() const { | 80 TestingObserver* InnerObserver() const { |
| 81 return observer_to_remove_on_destruct_; | 81 return observer_to_remove_on_destruct_; |
| 82 } | 82 } |
| 83 bool ContextDestroyedCalled() const { return context_destroyed_called_; } | 83 bool ContextDestroyedCalled() const { return context_destroyed_called_; } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 explicit TestingObserver(DummyContext* context) | 86 explicit TestingObserver(DummyContext* context) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 context->NotifyContextDestroyed(); | 130 context->NotifyContextDestroyed(); |
| 131 EXPECT_EQ(observer->InnerObserver(), nullptr); | 131 EXPECT_EQ(observer->InnerObserver(), nullptr); |
| 132 context = nullptr; | 132 context = nullptr; |
| 133 ThreadState::Current()->CollectAllGarbage(); | 133 ThreadState::Current()->CollectAllGarbage(); |
| 134 EXPECT_EQ(observer->LifecycleContext(), static_cast<DummyContext*>(0)); | 134 EXPECT_EQ(observer->LifecycleContext(), static_cast<DummyContext*>(0)); |
| 135 EXPECT_TRUE(observer->ContextDestroyedCalled()); | 135 EXPECT_TRUE(observer->ContextDestroyedCalled()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |