Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 class Visitor; | 39 class Visitor; |
| 40 | 40 |
| 41 template <typename T> | 41 template <typename T> |
| 42 class LifecycleContext { | 42 class LifecycleContext { |
| 43 public: | 43 public: |
| 44 typedef LifecycleNotifier<T> Notifier; | 44 typedef LifecycleNotifier<T> Notifier; |
| 45 typedef LifecycleObserver<T> Observer; | 45 typedef LifecycleObserver<T> Observer; |
| 46 | 46 |
| 47 LifecycleContext() { } | 47 LifecycleContext() { } |
| 48 virtual ~LifecycleContext() { } | 48 virtual ~LifecycleContext() |
| 49 { | |
| 50 ASSERT(!m_lifecycleNotifier); | |
|
sof
2014/12/26 08:21:42
Add a comment next to this to indicate what might
| |
| 51 } | |
| 49 | 52 |
| 50 virtual bool isContextThread() const { return true; } | 53 virtual bool isContextThread() const { return true; } |
| 51 | 54 |
| 52 // Called from the constructor of observers. | 55 // Called from the constructor of observers. |
| 53 void wasObservedBy(Observer*); | 56 void wasObservedBy(Observer*); |
| 54 | 57 |
| 55 // Called from the destructor of observers. | 58 // Called from the destructor of observers. |
| 56 void wasUnobservedBy(Observer*); | 59 void wasUnobservedBy(Observer*); |
| 57 | 60 |
| 58 virtual void trace(Visitor*) { } | 61 virtual void trace(Visitor*) { } |
| 59 | 62 |
| 60 protected: | 63 protected: |
| 61 Notifier& lifecycleNotifier(); | 64 Notifier& lifecycleNotifier(); |
| 65 void contextDestroyed() | |
|
sof
2014/12/26 08:21:42
nit: add an empty line.
| |
| 66 { | |
| 67 if (m_lifecycleNotifier) { | |
| 68 m_lifecycleNotifier->contextDestroyed(); | |
| 69 m_lifecycleNotifier.clear(); | |
| 70 } | |
| 71 } | |
| 62 | 72 |
| 63 private: | 73 private: |
| 64 PassOwnPtr<Notifier> createLifecycleNotifier(); | 74 PassOwnPtr<Notifier> createLifecycleNotifier(); |
| 65 | 75 |
| 66 OwnPtr<Notifier> m_lifecycleNotifier; | 76 OwnPtr<Notifier> m_lifecycleNotifier; |
| 67 }; | 77 }; |
| 68 | 78 |
| 69 template<typename T> | 79 template<typename T> |
| 70 inline void LifecycleContext<T>::wasObservedBy(typename LifecycleContext<T>::Obs erver* observer) | 80 inline void LifecycleContext<T>::wasObservedBy(typename LifecycleContext<T>::Obs erver* observer) |
| 71 { | 81 { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 90 | 100 |
| 91 template<typename T> | 101 template<typename T> |
| 92 inline PassOwnPtr<typename LifecycleContext<T>::Notifier> LifecycleContext<T>::c reateLifecycleNotifier() | 102 inline PassOwnPtr<typename LifecycleContext<T>::Notifier> LifecycleContext<T>::c reateLifecycleNotifier() |
| 93 { | 103 { |
| 94 return LifecycleContext<T>::Notifier::create(static_cast<T*>(this)); | 104 return LifecycleContext<T>::Notifier::create(static_cast<T*>(this)); |
| 95 } | 105 } |
| 96 | 106 |
| 97 } // namespace blink | 107 } // namespace blink |
| 98 | 108 |
| 99 #endif // LifecycleContext_h | 109 #endif // LifecycleContext_h |
| OLD | NEW |