OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 21 matching lines...) Expand all Loading... |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 template <typename Context, typename Observer> | 34 template <typename Context, typename Observer> |
35 class LifecycleNotifier; | 35 class LifecycleNotifier; |
36 | 36 |
37 template <typename Context, typename Observer> | 37 template <typename Context, typename Observer> |
38 class LifecycleObserver : public GarbageCollectedMixin { | 38 class LifecycleObserver : public GarbageCollectedMixin { |
39 public: | 39 public: |
40 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_lifecycleContext); } | 40 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_lifecycleContext); } |
41 | 41 |
42 virtual void contextDestroyed(Context*) {} | |
43 | |
44 Context* lifecycleContext() const { return m_lifecycleContext; } | 42 Context* lifecycleContext() const { return m_lifecycleContext; } |
45 | 43 |
46 void clearContext() { setContext(nullptr); } | 44 void clearContext() { setContext(nullptr); } |
47 | 45 |
48 protected: | 46 protected: |
49 explicit LifecycleObserver(Context* context) : m_lifecycleContext(nullptr) { | 47 explicit LifecycleObserver(Context* context) : m_lifecycleContext(nullptr) { |
50 setContext(context); | 48 setContext(context); |
51 } | 49 } |
52 | 50 |
53 void setContext(Context*); | 51 void setContext(Context*); |
(...skipping 15 matching lines...) Expand all Loading... |
69 | 67 |
70 if (m_lifecycleContext) { | 68 if (m_lifecycleContext) { |
71 static_cast<Notifier*>(m_lifecycleContext) | 69 static_cast<Notifier*>(m_lifecycleContext) |
72 ->addObserver(static_cast<Observer*>(this)); | 70 ->addObserver(static_cast<Observer*>(this)); |
73 } | 71 } |
74 } | 72 } |
75 | 73 |
76 } // namespace blink | 74 } // namespace blink |
77 | 75 |
78 #endif // LifecycleObserver_h | 76 #endif // LifecycleObserver_h |
OLD | NEW |