| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 Google 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/dom/DocumentLifecycleObserver.h" | 28 #include "core/dom/DocumentLifecycleObserver.h" |
| 29 | 29 |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 | 31 |
| 32 namespace WebCore { | 32 namespace WebCore { |
| 33 | 33 |
| 34 DocumentLifecycleObserver::DocumentLifecycleObserver(Document* document) | 34 DocumentLifecycleObserver::DocumentLifecycleObserver(Document* document) |
| 35 : ContextDestructionObserver(document, DocumentLifecycleObserverType) | 35 : ContextDestructionObserver(document) |
| 36 { | 36 { |
| 37 document->addLifecycleObserver(this); |
| 37 } | 38 } |
| 38 | 39 |
| 39 DocumentLifecycleObserver::~DocumentLifecycleObserver() | 40 PassOwnPtr<DocumentLifecycleNotifier> DocumentLifecycleNotifier::create() |
| 40 { | 41 { |
| 41 observeContext(0, DocumentLifecycleObserverType); | 42 return adoptPtr(new DocumentLifecycleNotifier()); |
| 42 } | 43 } |
| 43 | 44 |
| 44 DocumentLifecycleNotifier::DocumentLifecycleNotifier(ScriptExecutionContext* con
text) | 45 void DocumentLifecycleNotifier::addObserver(DocumentLifecycleObserver* observer) |
| 45 : ContextLifecycleNotifier(context) | |
| 46 { | 46 { |
| 47 } | 47 ASSERT(!m_iterating); |
| 48 | 48 ASSERT(!m_observers.contains(observer)); |
| 49 void DocumentLifecycleNotifier::addObserver(ContextDestructionObserver* observer
, ContextDestructionObserver::Type as) | 49 m_observers.append(observer); |
| 50 { | |
| 51 RELEASE_ASSERT(!m_iterating); | |
| 52 if (as == ContextDestructionObserver::DocumentLifecycleObserverType) | |
| 53 m_documentObservers.add(static_cast<DocumentLifecycleObserver*>(observer
)); | |
| 54 ContextLifecycleNotifier::addObserver(observer, as); | |
| 55 } | |
| 56 | |
| 57 void DocumentLifecycleNotifier::removeObserver(ContextDestructionObserver* obser
ver, ContextDestructionObserver::Type as) | |
| 58 { | |
| 59 RELEASE_ASSERT(!m_iterating); | |
| 60 if (as == ContextDestructionObserver::DocumentLifecycleObserverType) | |
| 61 m_documentObservers.remove(static_cast<DocumentLifecycleObserver*>(obser
ver)); | |
| 62 ContextLifecycleNotifier::removeObserver(observer, as); | |
| 63 } | 50 } |
| 64 | 51 |
| 65 } // namespace WebCore | 52 } // namespace WebCore |
| OLD | NEW |