| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 public: | 118 public: |
| 119 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, SecurityOrigin
* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureToken* userGe
stureToken) | 119 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, SecurityOrigin
* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureToken* userGe
stureToken) |
| 120 : SuspendableTimer(window.document()) | 120 : SuspendableTimer(window.document()) |
| 121 , m_event(event) | 121 , m_event(event) |
| 122 , m_window(&window) | 122 , m_window(&window) |
| 123 , m_targetOrigin(targetOrigin) | 123 , m_targetOrigin(targetOrigin) |
| 124 , m_stackTrace(stackTrace) | 124 , m_stackTrace(stackTrace) |
| 125 , m_userGestureToken(userGestureToken) | 125 , m_userGestureToken(userGestureToken) |
| 126 , m_disposalAllowed(true) | 126 , m_disposalAllowed(true) |
| 127 { | 127 { |
| 128 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti
ng(getExecutionContext(), "postMessage"); | 128 InspectorInstrumentation::asyncTaskScheduled(window.document(), "postMes
sage", this); |
| 129 } | 129 } |
| 130 | 130 |
| 131 MessageEvent* event() const { return m_event.get(); } | 131 MessageEvent* event() const { return m_event.get(); } |
| 132 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } | 132 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } |
| 133 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } | 133 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } |
| 134 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } | 134 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } |
| 135 void stop() override | 135 void stop() override |
| 136 { | 136 { |
| 137 SuspendableTimer::stop(); | 137 SuspendableTimer::stop(); |
| 138 | 138 |
| 139 if (m_disposalAllowed) | 139 if (m_disposalAllowed) |
| 140 dispose(); | 140 dispose(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Eager finalization is needed to promptly stop this timer object. | 143 // Eager finalization is needed to promptly stop this timer object. |
| 144 // (see DOMTimer comment for more.) | 144 // (see DOMTimer comment for more.) |
| 145 EAGERLY_FINALIZE(); | 145 EAGERLY_FINALIZE(); |
| 146 DEFINE_INLINE_VIRTUAL_TRACE() | 146 DEFINE_INLINE_VIRTUAL_TRACE() |
| 147 { | 147 { |
| 148 visitor->trace(m_event); | 148 visitor->trace(m_event); |
| 149 visitor->trace(m_window); | 149 visitor->trace(m_window); |
| 150 SuspendableTimer::trace(visitor); | 150 SuspendableTimer::trace(visitor); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specif
ic default task runner. | 153 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specif
ic default task runner. |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 void fired() override | 156 void fired() override |
| 157 { | 157 { |
| 158 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA
syncOperationCompletedCallbackStarting(getExecutionContext(), m_asyncOperationId
); | 158 InspectorInstrumentation::AsyncTask asyncTask(m_window->document(), this
); |
| 159 m_disposalAllowed = false; | 159 m_disposalAllowed = false; |
| 160 m_window->postMessageTimerFired(this); | 160 m_window->postMessageTimerFired(this); |
| 161 dispose(); | 161 dispose(); |
| 162 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | |
| 163 } | 162 } |
| 164 | 163 |
| 165 void dispose() | 164 void dispose() |
| 166 { | 165 { |
| 167 // Oilpan optimization: unregister as an observer right away. | 166 // Oilpan optimization: unregister as an observer right away. |
| 168 clearContext(); | 167 clearContext(); |
| 169 // Will destroy this object, now or after the next GC depending | 168 // Will destroy this object, now or after the next GC depending |
| 170 // on whether Oilpan is disabled or not. | 169 // on whether Oilpan is disabled or not. |
| 171 m_window->removePostMessageTimer(this); | 170 m_window->removePostMessageTimer(this); |
| 172 } | 171 } |
| 173 | 172 |
| 174 Member<MessageEvent> m_event; | 173 Member<MessageEvent> m_event; |
| 175 Member<LocalDOMWindow> m_window; | 174 Member<LocalDOMWindow> m_window; |
| 176 RefPtr<SecurityOrigin> m_targetOrigin; | 175 RefPtr<SecurityOrigin> m_targetOrigin; |
| 177 RefPtr<ScriptCallStack> m_stackTrace; | 176 RefPtr<ScriptCallStack> m_stackTrace; |
| 178 RefPtr<UserGestureToken> m_userGestureToken; | 177 RefPtr<UserGestureToken> m_userGestureToken; |
| 179 int m_asyncOperationId; | |
| 180 bool m_disposalAllowed; | 178 bool m_disposalAllowed; |
| 181 }; | 179 }; |
| 182 | 180 |
| 183 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL
istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType) | 181 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL
istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType) |
| 184 { | 182 { |
| 185 Platform::current()->suddenTerminationChanged(!addedListener); | 183 Platform::current()->suddenTerminationChanged(!addedListener); |
| 186 if (domWindow->frame() && domWindow->frame()->loader().client()) | 184 if (domWindow->frame() && domWindow->frame()->loader().client()) |
| 187 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
addedListener, disablerType); | 185 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged(
addedListener, disablerType); |
| 188 } | 186 } |
| 189 | 187 |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 { | 1514 { |
| 1517 // If the LocalDOMWindow still has a frame reference, that frame must point | 1515 // If the LocalDOMWindow still has a frame reference, that frame must point |
| 1518 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1516 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
| 1519 // where script execution leaks between different LocalDOMWindows. | 1517 // where script execution leaks between different LocalDOMWindows. |
| 1520 if (m_frameObserver->frame()) | 1518 if (m_frameObserver->frame()) |
| 1521 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1519 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
| 1522 return m_frameObserver->frame(); | 1520 return m_frameObserver->frame(); |
| 1523 } | 1521 } |
| 1524 | 1522 |
| 1525 } // namespace blink | 1523 } // namespace blink |
| OLD | NEW |