| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 DEFINE_TRACE(WindowProxy) { | 94 DEFINE_TRACE(WindowProxy) { |
| 95 visitor->trace(m_frame); | 95 visitor->trace(m_frame); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void WindowProxy::disposeContext(GlobalDetachmentBehavior behavior) { | 98 void WindowProxy::disposeContext(GlobalDetachmentBehavior behavior) { |
| 99 if (!isContextInitialized()) | 99 if (!isContextInitialized()) |
| 100 return; | 100 return; |
| 101 | 101 |
| 102 v8::HandleScope handleScope(m_isolate); | 102 ScriptState::Scope scope(m_scriptState.get()); |
| 103 v8::Local<v8::Context> context = m_scriptState->context(); | 103 v8::Local<v8::Context> context = m_scriptState->context(); |
| 104 if (m_frame->isLocalFrame()) { | 104 if (m_frame->isLocalFrame()) { |
| 105 LocalFrame* frame = toLocalFrame(m_frame); | 105 LocalFrame* frame = toLocalFrame(m_frame); |
| 106 // The embedder could run arbitrary code in response to the | 106 // The embedder could run arbitrary code in response to the |
| 107 // willReleaseScriptContext callback, so all disposing should happen after | 107 // willReleaseScriptContext callback, so all disposing should happen after |
| 108 // it returns. | 108 // it returns. |
| 109 frame->loader().client()->willReleaseScriptContext(context, | 109 frame->loader().client()->willReleaseScriptContext(context, |
| 110 m_world->worldId()); | 110 m_world->worldId()); |
| 111 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); | 111 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); |
| 112 } | 112 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 129 m_scriptState->disposePerContextData(); | 129 m_scriptState->disposePerContextData(); |
| 130 | 130 |
| 131 // It's likely that disposing the context has created a lot of | 131 // It's likely that disposing the context has created a lot of |
| 132 // garbage. Notify V8 about this so it'll have a chance of cleaning | 132 // garbage. Notify V8 about this so it'll have a chance of cleaning |
| 133 // it up when idle. | 133 // it up when idle. |
| 134 V8GCForContextDispose::instance().notifyContextDisposed( | 134 V8GCForContextDispose::instance().notifyContextDisposed( |
| 135 m_frame->isMainFrame()); | 135 m_frame->isMainFrame()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void WindowProxy::clearForClose() { | 138 void WindowProxy::clearForClose() { |
| 139 if (!isContextInitialized()) | |
| 140 return; | |
| 141 | |
| 142 disposeContext(DoNotDetachGlobal); | 139 disposeContext(DoNotDetachGlobal); |
| 143 } | 140 } |
| 144 | 141 |
| 145 void WindowProxy::clearForNavigation() { | 142 void WindowProxy::clearForNavigation() { |
| 146 if (!isContextInitialized()) | |
| 147 return; | |
| 148 | |
| 149 ScriptState::Scope scope(m_scriptState.get()); | |
| 150 | |
| 151 disposeContext(DetachGlobal); | 143 disposeContext(DetachGlobal); |
| 152 } | 144 } |
| 153 | 145 |
| 154 v8::Local<v8::Object> WindowProxy::globalIfNotDetached() { | 146 v8::Local<v8::Object> WindowProxy::globalIfNotDetached() { |
| 155 if (!isContextInitialized()) | 147 if (!isContextInitialized()) |
| 156 return v8::Local<v8::Object>(); | 148 return v8::Local<v8::Object>(); |
| 157 DCHECK(m_scriptState->contextIsValid()); | 149 DCHECK(m_scriptState->contextIsValid()); |
| 158 DCHECK(m_globalProxy == m_scriptState->context()->Global()); | 150 DCHECK(m_globalProxy == m_scriptState->context()->Global()); |
| 159 return m_globalProxy.newLocal(m_isolate); | 151 return m_globalProxy.newLocal(m_isolate); |
| 160 } | 152 } |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 .ToChecked(); | 551 .ToChecked(); |
| 560 } | 552 } |
| 561 | 553 |
| 562 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { | 554 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { |
| 563 if (!isContextInitialized()) | 555 if (!isContextInitialized()) |
| 564 return; | 556 return; |
| 565 setSecurityToken(origin); | 557 setSecurityToken(origin); |
| 566 } | 558 } |
| 567 | 559 |
| 568 } // namespace blink | 560 } // namespace blink |
| OLD | NEW |