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

Side by Side Diff: Source/core/dom/ContextLifecycleNotifier.cpp

Issue 991763002: Remove unnecessary add/removeObserver lifetime notifier indirections. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « Source/core/dom/ContextLifecycleNotifier.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
31 #include "core/dom/ActiveDOMObject.h" 31 #include "core/dom/ActiveDOMObject.h"
32 #include "wtf/TemporaryChange.h" 32 #include "wtf/TemporaryChange.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 ContextLifecycleNotifier::ContextLifecycleNotifier(ExecutionContext* context) 36 ContextLifecycleNotifier::ContextLifecycleNotifier(ExecutionContext* context)
37 : LifecycleNotifier<ExecutionContext, ContextLifecycleObserver>(context) 37 : LifecycleNotifier<ExecutionContext, ContextLifecycleObserver>(context)
38 { 38 {
39 } 39 }
40 40
41 void ContextLifecycleNotifier::addObserver(ContextLifecycleObserver* observer) 41 void ContextLifecycleNotifier::addObserver(ContextLifecycleObserver* observer)
haraken 2015/03/09 10:47:45 Do we still need this?
sof 2015/03/09 10:51:44 I'd argue that we still want that RELEASE_ASSERT()
42 { 42 {
43 LifecycleNotifier<ExecutionContext, ContextLifecycleObserver>::addObserver(o bserver); 43 LifecycleNotifier<ExecutionContext, ContextLifecycleObserver>::addObserver(o bserver);
44 if (observer->observerType() == ContextLifecycleObserver::ActiveDOMObjectTyp e) 44 if (observer->observerType() == ContextLifecycleObserver::ActiveDOMObjectTyp e)
45 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); 45 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
46 } 46 }
47 47
48 void ContextLifecycleNotifier::removeObserver(ContextLifecycleObserver* observer )
49 {
50 LifecycleNotifier<ExecutionContext, ContextLifecycleObserver>::removeObserve r(observer);
51 }
52
53 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() 48 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects()
54 { 49 {
55 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje cts); 50 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje cts);
56 Vector<ContextLifecycleObserver*> snapshotOfObservers; 51 Vector<ContextLifecycleObserver*> snapshotOfObservers;
57 copyToVector(m_observers, snapshotOfObservers); 52 copyToVector(m_observers, snapshotOfObservers);
58 for (ContextLifecycleObserver* observer : snapshotOfObservers) { 53 for (ContextLifecycleObserver* observer : snapshotOfObservers) {
59 // FIXME: Oilpan: At the moment, it's possible that a ActiveDOMObject 54 // FIXME: Oilpan: At the moment, it's possible that a ActiveDOMObject
60 // observer is destructed while iterating. Once we enable Oilpan by defa ult 55 // observer is destructed while iterating. Once we enable Oilpan by defa ult
61 // for all LifecycleObserver<T>s, we can remove the hack by making m_obs ervers 56 // for all LifecycleObserver<T>s, we can remove the hack by making m_obs ervers
62 // a HeapHashSet<WeakMember<LifecycleObserver<T>>>. 57 // a HeapHashSet<WeakMember<LifecycleObserver<T>>>.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 continue; 137 continue;
143 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observe r); 138 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observe r);
144 if (activeDOMObject == object) 139 if (activeDOMObject == object)
145 return true; 140 return true;
146 } 141 }
147 return false; 142 return false;
148 } 143 }
149 #endif 144 #endif
150 145
151 } // namespace blink 146 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/ContextLifecycleNotifier.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698