Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "bindings/core/v8/LocalWindowProxy.h" | 31 #include "bindings/core/v8/LocalWindowProxy.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ConditionalFeaturesForCore.h" | 33 #include "bindings/core/v8/ConditionalFeaturesForCore.h" |
| 34 #include "bindings/core/v8/DOMWrapperWorld.h" | 34 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 35 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
| 36 #include "bindings/core/v8/ToV8.h" | 36 #include "bindings/core/v8/ToV8.h" |
| 37 #include "bindings/core/v8/V8Binding.h" | 37 #include "bindings/core/v8/V8Binding.h" |
| 38 #include "bindings/core/v8/V8DOMActivityLogger.h" | 38 #include "bindings/core/v8/V8DOMActivityLogger.h" |
| 39 #include "bindings/core/v8/V8DOMWrapper.h" | 39 #include "bindings/core/v8/V8DOMWrapper.h" |
| 40 #include "bindings/core/v8/V8GCForContextDispose.h" | |
| 40 #include "bindings/core/v8/V8HTMLDocument.h" | 41 #include "bindings/core/v8/V8HTMLDocument.h" |
| 41 #include "bindings/core/v8/V8HiddenValue.h" | 42 #include "bindings/core/v8/V8HiddenValue.h" |
| 42 #include "bindings/core/v8/V8Initializer.h" | 43 #include "bindings/core/v8/V8Initializer.h" |
| 43 #include "bindings/core/v8/V8PagePopupControllerBinding.h" | 44 #include "bindings/core/v8/V8PagePopupControllerBinding.h" |
| 44 #include "bindings/core/v8/V8PrivateProperty.h" | 45 #include "bindings/core/v8/V8PrivateProperty.h" |
| 45 #include "bindings/core/v8/V8Window.h" | 46 #include "bindings/core/v8/V8Window.h" |
| 46 #include "core/dom/Modulator.h" | 47 #include "core/dom/Modulator.h" |
| 47 #include "core/frame/LocalFrame.h" | 48 #include "core/frame/LocalFrame.h" |
| 48 #include "core/frame/LocalFrameClient.h" | 49 #include "core/frame/LocalFrameClient.h" |
| 49 #include "core/frame/csp/ContentSecurityPolicy.h" | 50 #include "core/frame/csp/ContentSecurityPolicy.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 70 | 71 |
| 71 ScriptState::Scope scope(m_scriptState.get()); | 72 ScriptState::Scope scope(m_scriptState.get()); |
| 72 v8::Local<v8::Context> context = m_scriptState->context(); | 73 v8::Local<v8::Context> context = m_scriptState->context(); |
| 73 // The embedder could run arbitrary code in response to the | 74 // The embedder could run arbitrary code in response to the |
| 74 // willReleaseScriptContext callback, so all disposing should happen after | 75 // willReleaseScriptContext callback, so all disposing should happen after |
| 75 // it returns. | 76 // it returns. |
| 76 frame()->loader().client()->willReleaseScriptContext(context, | 77 frame()->loader().client()->willReleaseScriptContext(context, |
| 77 m_world->worldId()); | 78 m_world->worldId()); |
| 78 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); | 79 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); |
| 79 | 80 |
| 80 WindowProxy::disposeContext(behavior); | 81 if (behavior == DetachGlobal) { |
| 82 v8::Local<v8::Context> context = m_scriptState->context(); | |
| 83 // Clean up state on the global proxy, which will be reused. | |
| 84 if (!m_globalProxy.isEmpty()) { | |
| 85 // TODO(yukishiino): This DCHECK failed on Canary (M57) and Dev (M56). | |
| 86 // We need to figure out why m_globalProxy != context->Global(). | |
| 87 DCHECK(m_globalProxy == context->Global()); | |
| 88 DCHECK_EQ(toScriptWrappable(context->Global()), | |
| 89 toScriptWrappable( | |
| 90 context->Global()->GetPrototype().As<v8::Object>())); | |
| 91 m_globalProxy.get().SetWrapperClassId(0); | |
| 92 } | |
| 93 V8DOMWrapper::clearNativeInfo(isolate(), context->Global()); | |
|
haraken
2017/03/08 06:21:37
Is your crash related to the fact that we're expli
dcheng
2017/03/08 06:46:40
It's unclear. In theory, we shouldn't clear the in
| |
| 94 m_scriptState->detachGlobalObject(); | |
| 95 } | |
| 96 | |
| 97 m_scriptState->disposePerContextData(); | |
| 98 | |
| 99 // It's likely that disposing the context has created a lot of | |
| 100 // garbage. Notify V8 about this so it'll have a chance of cleaning | |
| 101 // it up when idle. | |
| 102 V8GCForContextDispose::instance().notifyContextDisposed( | |
| 103 frame()->isMainFrame()); | |
| 104 | |
| 105 DCHECK(m_lifecycle == Lifecycle::ContextInitialized); | |
| 106 m_lifecycle = Lifecycle::ContextDetached; | |
| 81 } | 107 } |
| 82 | 108 |
| 83 void LocalWindowProxy::initialize() { | 109 void LocalWindowProxy::initialize() { |
| 84 TRACE_EVENT1("v8", "LocalWindowProxy::initialize", "isMainWindow", | 110 TRACE_EVENT1("v8", "LocalWindowProxy::initialize", "isMainWindow", |
| 85 frame()->isMainFrame()); | 111 frame()->isMainFrame()); |
| 86 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( | 112 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( |
| 87 frame()->isMainFrame() ? "Blink.Binding.InitializeMainWindowProxy" | 113 frame()->isMainFrame() ? "Blink.Binding.InitializeMainWindowProxy" |
| 88 : "Blink.Binding.InitializeNonMainWindowProxy"); | 114 : "Blink.Binding.InitializeNonMainWindowProxy"); |
| 89 | 115 |
| 90 ScriptForbiddenScope::AllowUserAgentScript allowScript; | 116 ScriptForbiddenScope::AllowUserAgentScript allowScript; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 | 431 |
| 406 setSecurityToken(origin); | 432 setSecurityToken(origin); |
| 407 } | 433 } |
| 408 | 434 |
| 409 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, | 435 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, |
| 410 LocalFrame& frame, | 436 LocalFrame& frame, |
| 411 RefPtr<DOMWrapperWorld> world) | 437 RefPtr<DOMWrapperWorld> world) |
| 412 : WindowProxy(isolate, frame, std::move(world)) {} | 438 : WindowProxy(isolate, frame, std::move(world)) {} |
| 413 | 439 |
| 414 } // namespace blink | 440 } // namespace blink |
| OLD | NEW |