| 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 16 matching lines...) Expand all Loading... |
| 27 #define PageLifecycleNotifier_h | 27 #define PageLifecycleNotifier_h |
| 28 | 28 |
| 29 #include "core/page/PageLifecycleObserver.h" | 29 #include "core/page/PageLifecycleObserver.h" |
| 30 #include "core/platform/LifecycleNotifier.h" | 30 #include "core/platform/LifecycleNotifier.h" |
| 31 #include "wtf/PassOwnPtr.h" | 31 #include "wtf/PassOwnPtr.h" |
| 32 #include "wtf/TemporaryChange.h" | 32 #include "wtf/TemporaryChange.h" |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 class Page; | 36 class Page; |
| 37 class Frame; |
| 37 | 38 |
| 38 class PageLifecycleNotifier : public LifecycleNotifier { | 39 class PageLifecycleNotifier : public LifecycleNotifier { |
| 39 public: | 40 public: |
| 40 static PassOwnPtr<PageLifecycleNotifier> create(LifecycleContext*); | 41 static PassOwnPtr<PageLifecycleNotifier> create(LifecycleContext*); |
| 41 | 42 |
| 42 void notifyPageVisibilityChanged(); | 43 void notifyPageVisibilityChanged(); |
| 44 void notifyDidCommitLoad(Frame*); |
| 43 | 45 |
| 44 virtual void addObserver(LifecycleObserver*, LifecycleObserver::Type) OVERRI
DE; | 46 virtual void addObserver(LifecycleObserver*, LifecycleObserver::Type) OVERRI
DE; |
| 45 virtual void removeObserver(LifecycleObserver*, LifecycleObserver::Type) OVE
RRIDE; | 47 virtual void removeObserver(LifecycleObserver*, LifecycleObserver::Type) OVE
RRIDE; |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 explicit PageLifecycleNotifier(LifecycleContext*); | 50 explicit PageLifecycleNotifier(LifecycleContext*); |
| 49 | 51 |
| 50 typedef HashSet<PageLifecycleObserver*> PageObserverSet; | 52 typedef HashSet<PageLifecycleObserver*> PageObserverSet; |
| 51 PageObserverSet m_pageObservers; | 53 PageObserverSet m_pageObservers; |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 inline PassOwnPtr<PageLifecycleNotifier> PageLifecycleNotifier::create(Lifecycle
Context* context) | 56 inline PassOwnPtr<PageLifecycleNotifier> PageLifecycleNotifier::create(Lifecycle
Context* context) |
| 55 { | 57 { |
| 56 return adoptPtr(new PageLifecycleNotifier(context)); | 58 return adoptPtr(new PageLifecycleNotifier(context)); |
| 57 } | 59 } |
| 58 | 60 |
| 59 inline void PageLifecycleNotifier::notifyPageVisibilityChanged() | 61 inline void PageLifecycleNotifier::notifyPageVisibilityChanged() |
| 60 { | 62 { |
| 61 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverPageObs
ervers); | 63 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverPageObs
ervers); |
| 62 for (PageObserverSet::iterator it = m_pageObservers.begin(); it != m_pageObs
ervers.end(); ++it) | 64 for (PageObserverSet::iterator it = m_pageObservers.begin(); it != m_pageObs
ervers.end(); ++it) |
| 63 (*it)->pageVisibilityChanged(); | 65 (*it)->pageVisibilityChanged(); |
| 64 } | 66 } |
| 65 | 67 |
| 68 inline void PageLifecycleNotifier::notifyDidCommitLoad(Frame* frame) |
| 69 { |
| 70 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverPageObs
ervers); |
| 71 for (PageObserverSet::iterator it = m_pageObservers.begin(); it != m_pageObs
ervers.end(); ++it) |
| 72 (*it)->didCommitLoad(frame); |
| 73 } |
| 74 |
| 66 } // namespace WebCore | 75 } // namespace WebCore |
| 67 | 76 |
| 68 #endif // PageLifecycleNotifier_h | 77 #endif // PageLifecycleNotifier_h |
| OLD | NEW |