Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: Source/platform/LifecycleNotifier.h

Issue 218953002: Oilpan: IDBCursor should be detached from IDBRequest when the IDBRequest stops (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
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 29 matching lines...) Expand all
40 class LifecycleNotifier { 40 class LifecycleNotifier {
41 public: 41 public:
42 typedef LifecycleObserver<T> Observer; 42 typedef LifecycleObserver<T> Observer;
43 typedef T Context; 43 typedef T Context;
44 44
45 static PassOwnPtr<LifecycleNotifier> create(Context* context) 45 static PassOwnPtr<LifecycleNotifier> create(Context* context)
46 { 46 {
47 return adoptPtr(new LifecycleNotifier(context)); 47 return adoptPtr(new LifecycleNotifier(context));
48 } 48 }
49 49
50
51 virtual ~LifecycleNotifier(); 50 virtual ~LifecycleNotifier();
52 51
53
54 // FIXME: this won't need to be virtual anymore. 52 // FIXME: this won't need to be virtual anymore.
55 virtual void addObserver(Observer*); 53 virtual void addObserver(Observer*);
56 virtual void removeObserver(Observer*); 54 virtual void removeObserver(Observer*);
57 55
56 void notifyContextWillBeDestroyed();
58 bool isIteratingOverObservers() const { return m_iterating != IteratingNone; } 57 bool isIteratingOverObservers() const { return m_iterating != IteratingNone; }
59 58
60 protected: 59 protected:
61 explicit LifecycleNotifier(Context* context) 60 explicit LifecycleNotifier(Context* context)
62 : m_iterating(IteratingNone) 61 : m_iterating(IteratingNone)
63 , m_context(context) 62 , m_context(context)
64 { 63 {
65 } 64 }
66 65
67 Context* context() const { return m_context; } 66 Context* context() const { return m_context; }
(...skipping 23 matching lines...) Expand all
91 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverAll); 90 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverAll);
92 for (typename ObserverSet::iterator it = m_observers.begin(); it != m_observ ers.end(); it = m_observers.begin()) { 91 for (typename ObserverSet::iterator it = m_observers.begin(); it != m_observ ers.end(); it = m_observers.begin()) {
93 Observer* observer = *it; 92 Observer* observer = *it;
94 m_observers.remove(observer); 93 m_observers.remove(observer);
95 ASSERT(observer->lifecycleContext() == m_context); 94 ASSERT(observer->lifecycleContext() == m_context);
96 observer->contextDestroyed(); 95 observer->contextDestroyed();
97 } 96 }
98 } 97 }
99 98
100 template<typename T> 99 template<typename T>
100 inline void LifecycleNotifier<T>::notifyContextWillBeDestroyed()
101 {
102 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverAll);
103 for (typename ObserverSet::iterator it = m_observers.begin(); it != m_observ ers.end(); it = m_observers.begin()) {
104 Observer* observer = *it;
105 ASSERT(observer->lifecycleContext() == m_context);
106 observer->contextWillBeDestroyed();
107 }
108 }
109
110 template<typename T>
101 inline void LifecycleNotifier<T>::addObserver(typename LifecycleNotifier<T>::Obs erver* observer) 111 inline void LifecycleNotifier<T>::addObserver(typename LifecycleNotifier<T>::Obs erver* observer)
102 { 112 {
103 RELEASE_ASSERT(m_iterating != IteratingOverAll); 113 RELEASE_ASSERT(m_iterating != IteratingOverAll);
104 m_observers.add(observer); 114 m_observers.add(observer);
105 } 115 }
106 116
107 template<typename T> 117 template<typename T>
108 inline void LifecycleNotifier<T>::removeObserver(typename LifecycleNotifier<T>:: Observer* observer) 118 inline void LifecycleNotifier<T>::removeObserver(typename LifecycleNotifier<T>:: Observer* observer)
109 { 119 {
110 RELEASE_ASSERT(m_iterating != IteratingOverAll); 120 RELEASE_ASSERT(m_iterating != IteratingOverAll);
111 m_observers.remove(observer); 121 m_observers.remove(observer);
112 } 122 }
113 123
114 124
115 125
116 } // namespace WebCore 126 } // namespace WebCore
117 127
118 #endif // LifecycleNotifier_h 128 #endif // LifecycleNotifier_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698