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 19 matching lines...) Expand all Loading... | |
30 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
31 #include "wtf/Assertions.h" | 31 #include "wtf/Assertions.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 template<typename T, typename Observer, typename Notifier> | 35 template<typename T, typename Observer, typename Notifier> |
36 class LifecycleObserver : public WillBeGarbageCollectedMixin { | 36 class LifecycleObserver : public WillBeGarbageCollectedMixin { |
37 public: | 37 public: |
38 using Context = T; | 38 using Context = T; |
39 | 39 |
40 LifecycleObserver() | 40 LifecycleObserver(Context* context) |
haraken
2015/03/23 14:30:43
Add explicit.
sof
2015/03/23 15:06:29
Done, along with making the ctor protected.
| |
41 : m_lifecycleContext(nullptr) | 41 : m_lifecycleContext(nullptr) |
42 { | 42 { |
43 setContext(context); | |
43 } | 44 } |
44 | 45 |
45 #if !ENABLE(OILPAN) | 46 #if !ENABLE(OILPAN) |
46 virtual ~LifecycleObserver() | 47 virtual ~LifecycleObserver() |
47 { | 48 { |
48 dispose(); | 49 dispose(); |
49 } | 50 } |
50 #endif | 51 #endif |
51 | 52 |
52 DEFINE_INLINE_VIRTUAL_TRACE() | 53 DEFINE_INLINE_VIRTUAL_TRACE() |
(...skipping 25 matching lines...) Expand all Loading... | |
78 | 79 |
79 m_lifecycleContext = context; | 80 m_lifecycleContext = context; |
80 | 81 |
81 if (m_lifecycleContext) | 82 if (m_lifecycleContext) |
82 static_cast<Notifier*>(m_lifecycleContext.get())->addObserver(static_cas t<Observer*>(this)); | 83 static_cast<Notifier*>(m_lifecycleContext.get())->addObserver(static_cas t<Observer*>(this)); |
83 } | 84 } |
84 | 85 |
85 } // namespace blink | 86 } // namespace blink |
86 | 87 |
87 #endif // LifecycleObserver_h | 88 #endif // LifecycleObserver_h |
OLD | NEW |