| 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 19 matching lines...) Expand all Loading... |
| 30 public: | 30 public: |
| 31 explicit Observer(ExecutionContext* executionContext) | 31 explicit Observer(ExecutionContext* executionContext) |
| 32 : ContextLifecycleObserver(executionContext) | 32 : ContextLifecycleObserver(executionContext) |
| 33 { | 33 { |
| 34 if (executionContext) | 34 if (executionContext) |
| 35 executionContext->allowWindowInteraction(); | 35 executionContext->allowWindowInteraction(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void dispose() | 38 void dispose() |
| 39 { | 39 { |
| 40 if (executionContext()) | 40 if (getExecutionContext()) |
| 41 executionContext()->consumeWindowInteraction(); | 41 getExecutionContext()->consumeWindowInteraction(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 DEFINE_INLINE_TRACE() | 44 DEFINE_INLINE_TRACE() |
| 45 { | 45 { |
| 46 ContextLifecycleObserver::trace(visitor); | 46 ContextLifecycleObserver::trace(visitor); |
| 47 } | 47 } |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // In Oilpan, destructors are not allowed to touch other on-heap objects. | 50 // In Oilpan, destructors are not allowed to touch other on-heap objects. |
| 51 // The Observer indirection is needed to keep | 51 // The Observer indirection is needed to keep |
| 52 // ScopedWindowFocusAllowedIndicator off-heap and thus allows its destructor | 52 // ScopedWindowFocusAllowedIndicator off-heap and thus allows its destructor |
| 53 // to call executionContext()->consumeWindowInteraction(). | 53 // to call getExecutionContext()->consumeWindowInteraction(). |
| 54 OwnPtrWillBePersistent<Observer> m_observer; | 54 OwnPtrWillBePersistent<Observer> m_observer; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } // namespace blink | 57 } // namespace blink |
| 58 | 58 |
| 59 #endif // ScopedWindowFocusAllowedIndicator_h | 59 #endif // ScopedWindowFocusAllowedIndicator_h |
| OLD | NEW |