| 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 18 matching lines...) Expand all Loading... |
| 29 #define LifecycleContext_h | 29 #define LifecycleContext_h |
| 30 | 30 |
| 31 #include "platform/LifecycleNotifier.h" | 31 #include "platform/LifecycleNotifier.h" |
| 32 #include "platform/LifecycleObserver.h" | 32 #include "platform/LifecycleObserver.h" |
| 33 #include "wtf/HashSet.h" | 33 #include "wtf/HashSet.h" |
| 34 #include "wtf/OwnPtr.h" | 34 #include "wtf/OwnPtr.h" |
| 35 #include "wtf/PassOwnPtr.h" | 35 #include "wtf/PassOwnPtr.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class Visitor; |
| 40 |
| 39 template <typename T> | 41 template <typename T> |
| 40 class LifecycleContext { | 42 class LifecycleContext { |
| 41 public: | 43 public: |
| 42 typedef LifecycleNotifier<T> Notifier; | 44 typedef LifecycleNotifier<T> Notifier; |
| 43 typedef LifecycleObserver<T> Observer; | 45 typedef LifecycleObserver<T> Observer; |
| 44 | 46 |
| 45 LifecycleContext() { } | 47 LifecycleContext() { } |
| 46 virtual ~LifecycleContext() { } | 48 virtual ~LifecycleContext() { } |
| 47 | 49 |
| 48 virtual bool isContextThread() const { return true; } | 50 virtual bool isContextThread() const { return true; } |
| 49 | 51 |
| 50 // Called from the constructor of observers. | 52 // Called from the constructor of observers. |
| 51 void wasObservedBy(Observer*); | 53 void wasObservedBy(Observer*); |
| 52 | 54 |
| 53 // Called from the destructor of observers. | 55 // Called from the destructor of observers. |
| 54 void wasUnobservedBy(Observer*); | 56 void wasUnobservedBy(Observer*); |
| 55 | 57 |
| 58 virtual void trace(Visitor*) { } |
| 59 |
| 56 protected: | 60 protected: |
| 57 Notifier& lifecycleNotifier(); | 61 Notifier& lifecycleNotifier(); |
| 58 | 62 |
| 59 private: | 63 private: |
| 60 PassOwnPtr<Notifier> createLifecycleNotifier(); | 64 PassOwnPtr<Notifier> createLifecycleNotifier(); |
| 61 | 65 |
| 62 OwnPtr<Notifier> m_lifecycleNotifier; | 66 OwnPtr<Notifier> m_lifecycleNotifier; |
| 63 }; | 67 }; |
| 64 | 68 |
| 65 template<typename T> | 69 template<typename T> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 86 | 90 |
| 87 template<typename T> | 91 template<typename T> |
| 88 inline PassOwnPtr<typename LifecycleContext<T>::Notifier> LifecycleContext<T>::c
reateLifecycleNotifier() | 92 inline PassOwnPtr<typename LifecycleContext<T>::Notifier> LifecycleContext<T>::c
reateLifecycleNotifier() |
| 89 { | 93 { |
| 90 return LifecycleContext<T>::Notifier::create(static_cast<T*>(this)); | 94 return LifecycleContext<T>::Notifier::create(static_cast<T*>(this)); |
| 91 } | 95 } |
| 92 | 96 |
| 93 } // namespace blink | 97 } // namespace blink |
| 94 | 98 |
| 95 #endif // LifecycleContext_h | 99 #endif // LifecycleContext_h |
| OLD | NEW |