| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ScopedWindowFocusAllowedIndicator_h | 5 #ifndef ScopedWindowFocusAllowedIndicator_h |
| 6 #define ScopedWindowFocusAllowedIndicator_h | 6 #define ScopedWindowFocusAllowedIndicator_h |
| 7 | 7 |
| 8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 class Observer final : public NoBaseWillBeGarbageCollectedFinalized<Observer
>, public ContextLifecycleObserver { | 27 class Observer final : public NoBaseWillBeGarbageCollectedFinalized<Observer
>, public ContextLifecycleObserver { |
| 28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Observer); | 28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Observer); |
| 29 public: | 29 public: |
| 30 explicit Observer(ExecutionContext* executionContext) | 30 explicit Observer(ExecutionContext* executionContext) |
| 31 : ContextLifecycleObserver(executionContext) | 31 : ContextLifecycleObserver(executionContext) |
| 32 { | 32 { |
| 33 if (executionContext) | 33 if (executionContext) |
| 34 executionContext->allowWindowInteraction(); | 34 executionContext->allowWindowFocus(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void dispose() | 37 void dispose() |
| 38 { | 38 { |
| 39 if (executionContext()) | 39 if (executionContext()) |
| 40 executionContext()->consumeWindowInteraction(); | 40 executionContext()->consumeWindowFocus(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void trace(Visitor* visitor) | 43 void trace(Visitor* visitor) |
| 44 { | 44 { |
| 45 ContextLifecycleObserver::trace(visitor); | 45 ContextLifecycleObserver::trace(visitor); |
| 46 } | 46 } |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // In Oilpan, destructors are not allowed to touch other on-heap objects. | 49 // In Oilpan, destructors are not allowed to touch other on-heap objects. |
| 50 // The Observer indirection is needed to keep | 50 // The Observer indirection is needed to keep |
| 51 // ScopedWindowFocusAllowedIndicator off-heap and thus allows its destructor | 51 // ScopedWindowFocusAllowedIndicator off-heap and thus allows its destructor |
| 52 // to call executionContext()->consumeWindowInteraction(). | 52 // to call executionContext()->consumeWindowFocus(). |
| 53 OwnPtrWillBePersistent<Observer> m_observer; | 53 OwnPtrWillBePersistent<Observer> m_observer; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace blink | 56 } // namespace blink |
| 57 | 57 |
| 58 #endif // ScopedWindowFocusAllowedIndicator_h | 58 #endif // ScopedWindowFocusAllowedIndicator_h |
| OLD | NEW |