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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 // The embedder could run arbitrary code in response to the | 108 // The embedder could run arbitrary code in response to the |
109 // willReleaseScriptContext callback, so all disposing should happen after | 109 // willReleaseScriptContext callback, so all disposing should happen after |
110 // it returns. | 110 // it returns. |
111 frame->loader().client()->willReleaseScriptContext(context, | 111 frame->loader().client()->willReleaseScriptContext(context, |
112 m_world->worldId()); | 112 m_world->worldId()); |
113 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); | 113 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); |
114 } | 114 } |
115 | 115 |
116 m_document.clear(); | 116 m_document.clear(); |
117 | 117 |
118 if (behavior == DetachGlobal) | 118 if (behavior == DetachGlobal) { |
119 // Clean up state on the global proxy, which will be reused. | |
120 // TODO(dcheng): Check if this is needed. | |
dcheng
2016/11/02 01:46:42
We only detach globals on navigation, so the inter
haraken
2016/11/02 04:30:32
Makes sense. Let's make the change in a separate C
dcheng
2016/11/02 07:45:32
It kind of makes sense in this CL though? Previous
Yuki
2016/11/02 08:26:39
I vote to keep |clearNativeInfo| here. Just my pr
| |
121 V8DOMWrapper::clearNativeInfo(m_isolate, context->Global()); | |
119 m_scriptState->detachGlobalObject(); | 122 m_scriptState->detachGlobalObject(); |
123 } | |
120 | 124 |
121 m_scriptState->disposePerContextData(); | 125 m_scriptState->disposePerContextData(); |
122 | 126 |
123 // It's likely that disposing the context has created a lot of | 127 // It's likely that disposing the context has created a lot of |
124 // garbage. Notify V8 about this so it'll have a chance of cleaning | 128 // garbage. Notify V8 about this so it'll have a chance of cleaning |
125 // it up when idle. | 129 // it up when idle. |
126 V8GCForContextDispose::instance().notifyContextDisposed( | 130 V8GCForContextDispose::instance().notifyContextDisposed( |
127 m_frame->isMainFrame()); | 131 m_frame->isMainFrame()); |
128 } | 132 } |
129 | 133 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 // object is created together with a new v8::Context, but the global proxy | 363 // object is created together with a new v8::Context, but the global proxy |
360 // object doesn't change. | 364 // object doesn't change. |
361 // [3] WindowProperties is a named properties object of Window interface. | 365 // [3] WindowProperties is a named properties object of Window interface. |
362 | 366 |
363 DOMWindow* window = m_frame->domWindow(); | 367 DOMWindow* window = m_frame->domWindow(); |
364 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); | 368 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); |
365 | 369 |
366 v8::Local<v8::Context> context = m_scriptState->context(); | 370 v8::Local<v8::Context> context = m_scriptState->context(); |
367 // The global proxy object. Note this is not the global object. | 371 // The global proxy object. Note this is not the global object. |
368 v8::Local<v8::Object> globalProxy = context->Global(); | 372 v8::Local<v8::Object> globalProxy = context->Global(); |
373 V8DOMWrapper::setNativeInfo(m_isolate, globalProxy, wrapperTypeInfo, window); | |
374 // Mark the handle to be traced by Oilpan, since the global proxy has a | |
375 // reference to the DOMWindow. | |
376 DCHECK(m_globalProxy == globalProxy); | |
377 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId); | |
haraken
2016/11/02 04:30:32
Can we call V8DOMWrapper::associateObjectWithWrapp
dcheng
2016/11/02 07:45:32
My concern with this is associateObjectWithWrapper
| |
369 // The global object, aka window wrapper object. | 378 // The global object, aka window wrapper object. |
370 v8::Local<v8::Object> windowWrapper = | 379 v8::Local<v8::Object> windowWrapper = |
371 globalProxy->GetPrototype().As<v8::Object>(); | 380 globalProxy->GetPrototype().As<v8::Object>(); |
372 windowWrapper = V8DOMWrapper::associateObjectWithWrapper( | 381 windowWrapper = V8DOMWrapper::associateObjectWithWrapper( |
373 m_isolate, window, wrapperTypeInfo, windowWrapper); | 382 m_isolate, window, wrapperTypeInfo, windowWrapper); |
374 // The prototype object of Window interface. | 383 // The prototype object of Window interface. |
375 v8::Local<v8::Object> windowPrototype = | 384 v8::Local<v8::Object> windowPrototype = |
376 windowWrapper->GetPrototype().As<v8::Object>(); | 385 windowWrapper->GetPrototype().As<v8::Object>(); |
377 RELEASE_ASSERT(!windowPrototype.IsEmpty()); | 386 RELEASE_ASSERT(!windowPrototype.IsEmpty()); |
378 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo, | 387 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 v8String(m_isolate, name)); | 586 v8String(m_isolate, name)); |
578 } | 587 } |
579 | 588 |
580 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { | 589 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { |
581 if (!isContextInitialized()) | 590 if (!isContextInitialized()) |
582 return; | 591 return; |
583 setSecurityToken(origin); | 592 setSecurityToken(origin); |
584 } | 593 } |
585 | 594 |
586 } // namespace blink | 595 } // namespace blink |
OLD | NEW |