| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // The embedder could run arbitrary code in response to the | 109 // The embedder could run arbitrary code in response to the |
| 110 // willReleaseScriptContext callback, so all disposing should happen after | 110 // willReleaseScriptContext callback, so all disposing should happen after |
| 111 // it returns. | 111 // it returns. |
| 112 frame->loader().client()->willReleaseScriptContext(context, | 112 frame->loader().client()->willReleaseScriptContext(context, |
| 113 m_world->worldId()); | 113 m_world->worldId()); |
| 114 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); | 114 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 m_document.clear(); | 117 m_document.clear(); |
| 118 | 118 |
| 119 if (behavior == DetachGlobal) | 119 if (behavior == DetachGlobal) { |
| 120 // Clean up state on the global proxy, which will be reused. |
| 121 // TODO(dcheng): Check if this is needed. |
| 122 V8DOMWrapper::clearNativeInfo(m_isolate, context->Global()); |
| 123 DCHECK(m_globalProxy == m_scriptState->context()->Global()); |
| 124 m_globalProxy.get().SetWrapperClassId(0); |
| 120 m_scriptState->detachGlobalObject(); | 125 m_scriptState->detachGlobalObject(); |
| 126 } |
| 121 | 127 |
| 122 m_scriptState->disposePerContextData(); | 128 m_scriptState->disposePerContextData(); |
| 123 | 129 |
| 124 // It's likely that disposing the context has created a lot of | 130 // It's likely that disposing the context has created a lot of |
| 125 // garbage. Notify V8 about this so it'll have a chance of cleaning | 131 // garbage. Notify V8 about this so it'll have a chance of cleaning |
| 126 // it up when idle. | 132 // it up when idle. |
| 127 V8GCForContextDispose::instance().notifyContextDisposed( | 133 V8GCForContextDispose::instance().notifyContextDisposed( |
| 128 m_frame->isMainFrame()); | 134 m_frame->isMainFrame()); |
| 129 } | 135 } |
| 130 | 136 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // object is created together with a new v8::Context, but the global proxy | 370 // object is created together with a new v8::Context, but the global proxy |
| 365 // object doesn't change. | 371 // object doesn't change. |
| 366 // [3] WindowProperties is a named properties object of Window interface. | 372 // [3] WindowProperties is a named properties object of Window interface. |
| 367 | 373 |
| 368 DOMWindow* window = m_frame->domWindow(); | 374 DOMWindow* window = m_frame->domWindow(); |
| 369 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); | 375 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); |
| 370 | 376 |
| 371 v8::Local<v8::Context> context = m_scriptState->context(); | 377 v8::Local<v8::Context> context = m_scriptState->context(); |
| 372 // The global proxy object. Note this is not the global object. | 378 // The global proxy object. Note this is not the global object. |
| 373 v8::Local<v8::Object> globalProxy = context->Global(); | 379 v8::Local<v8::Object> globalProxy = context->Global(); |
| 380 V8DOMWrapper::setNativeInfo(m_isolate, globalProxy, wrapperTypeInfo, window); |
| 381 // Mark the handle to be traced by Oilpan, since the global proxy has a |
| 382 // reference to the DOMWindow. |
| 383 DCHECK(m_globalProxy == globalProxy); |
| 384 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId); |
| 374 // The global object, aka window wrapper object. | 385 // The global object, aka window wrapper object. |
| 375 v8::Local<v8::Object> windowWrapper = | 386 v8::Local<v8::Object> windowWrapper = |
| 376 globalProxy->GetPrototype().As<v8::Object>(); | 387 globalProxy->GetPrototype().As<v8::Object>(); |
| 377 windowWrapper = V8DOMWrapper::associateObjectWithWrapper( | 388 windowWrapper = V8DOMWrapper::associateObjectWithWrapper( |
| 378 m_isolate, window, wrapperTypeInfo, windowWrapper); | 389 m_isolate, window, wrapperTypeInfo, windowWrapper); |
| 379 // The prototype object of Window interface. | 390 // The prototype object of Window interface. |
| 380 v8::Local<v8::Object> windowPrototype = | 391 v8::Local<v8::Object> windowPrototype = |
| 381 windowWrapper->GetPrototype().As<v8::Object>(); | 392 windowWrapper->GetPrototype().As<v8::Object>(); |
| 382 RELEASE_ASSERT(!windowPrototype.IsEmpty()); | 393 RELEASE_ASSERT(!windowPrototype.IsEmpty()); |
| 383 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo, | 394 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo, |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 v8String(m_isolate, name)); | 593 v8String(m_isolate, name)); |
| 583 } | 594 } |
| 584 | 595 |
| 585 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { | 596 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { |
| 586 if (!isContextInitialized()) | 597 if (!isContextInitialized()) |
| 587 return; | 598 return; |
| 588 setSecurityToken(origin); | 599 setSecurityToken(origin); |
| 589 } | 600 } |
| 590 | 601 |
| 591 } // namespace blink | 602 } // namespace blink |
| OLD | NEW |