Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/RemoteWindowProxy.cpp

Issue 2737553007: Duplicate WindowProxy::disposeContext() into subclasses. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "bindings/core/v8/WindowProxy.h" 31 #include "bindings/core/v8/RemoteWindowProxy.h"
dcheng 2017/03/08 06:09:32 I guess I never fixed this copy and paste error...
32 32
33 #include <algorithm> 33 #include <algorithm>
34 #include <utility> 34 #include <utility>
35 35
36 #include "bindings/core/v8/ConditionalFeatures.h"
dcheng 2017/03/08 06:09:32 Trim these headers now since they're all unused.
37 #include "bindings/core/v8/DOMWrapperWorld.h" 36 #include "bindings/core/v8/DOMWrapperWorld.h"
38 #include "bindings/core/v8/ScriptController.h"
39 #include "bindings/core/v8/ToV8.h"
40 #include "bindings/core/v8/V8Binding.h"
41 #include "bindings/core/v8/V8DOMActivityLogger.h"
42 #include "bindings/core/v8/V8DOMWrapper.h" 37 #include "bindings/core/v8/V8DOMWrapper.h"
43 #include "bindings/core/v8/V8Document.h"
44 #include "bindings/core/v8/V8GCForContextDispose.h" 38 #include "bindings/core/v8/V8GCForContextDispose.h"
45 #include "bindings/core/v8/V8HTMLCollection.h"
46 #include "bindings/core/v8/V8HTMLDocument.h"
47 #include "bindings/core/v8/V8HiddenValue.h"
48 #include "bindings/core/v8/V8Initializer.h" 39 #include "bindings/core/v8/V8Initializer.h"
49 #include "bindings/core/v8/V8ObjectConstructor.h"
50 #include "bindings/core/v8/V8PagePopupControllerBinding.h"
51 #include "bindings/core/v8/V8PrivateProperty.h"
52 #include "bindings/core/v8/V8Window.h" 40 #include "bindings/core/v8/V8Window.h"
53 #include "core/frame/LocalFrame.h"
54 #include "core/frame/LocalFrameClient.h"
55 #include "core/frame/csp/ContentSecurityPolicy.h"
56 #include "core/html/DocumentNameCollection.h"
57 #include "core/html/HTMLCollection.h"
58 #include "core/html/HTMLIFrameElement.h"
59 #include "core/inspector/InspectorInstrumentation.h"
60 #include "core/inspector/MainThreadDebugger.h"
61 #include "core/loader/DocumentLoader.h"
62 #include "core/loader/FrameLoader.h"
63 #include "core/origin_trials/OriginTrialContext.h"
64 #include "platform/Histogram.h" 41 #include "platform/Histogram.h"
65 #include "platform/RuntimeEnabledFeatures.h"
66 #include "platform/ScriptForbiddenScope.h" 42 #include "platform/ScriptForbiddenScope.h"
67 #include "platform/heap/Handle.h" 43 #include "platform/heap/Handle.h"
68 #include "platform/instrumentation/tracing/TraceEvent.h" 44 #include "platform/instrumentation/tracing/TraceEvent.h"
69 #include "platform/weborigin/SecurityOrigin.h"
70 #include "public/platform/Platform.h"
71 #include "v8/include/v8-debug.h"
72 #include "v8/include/v8.h" 45 #include "v8/include/v8.h"
73 #include "wtf/Assertions.h" 46 #include "wtf/Assertions.h"
74 #include "wtf/StringExtras.h"
75 #include "wtf/text/CString.h"
76 47
77 namespace blink { 48 namespace blink {
78 49
79 RemoteWindowProxy::RemoteWindowProxy(v8::Isolate* isolate, 50 RemoteWindowProxy::RemoteWindowProxy(v8::Isolate* isolate,
80 RemoteFrame& frame, 51 RemoteFrame& frame,
81 RefPtr<DOMWrapperWorld> world) 52 RefPtr<DOMWrapperWorld> world)
82 : WindowProxy(isolate, frame, std::move(world)) {} 53 : WindowProxy(isolate, frame, std::move(world)) {}
83 54
84 void RemoteWindowProxy::disposeContext(GlobalDetachmentBehavior behavior) { 55 void RemoteWindowProxy::disposeContext(GlobalDetachmentBehavior behavior) {
85 if (m_lifecycle != Lifecycle::ContextInitialized) 56 if (m_lifecycle != Lifecycle::ContextInitialized)
86 return; 57 return;
87 58
88 WindowProxy::disposeContext(behavior); 59 if (behavior == DetachGlobal) {
60 v8::Local<v8::Context> context = m_scriptState->context();
61 // Clean up state on the global proxy, which will be reused.
62 if (!m_globalProxy.isEmpty()) {
63 // TODO(yukishiino): This DCHECK failed on Canary (M57) and Dev (M56).
64 // We need to figure out why m_globalProxy != context->Global().
65 DCHECK(m_globalProxy == context->Global());
66 DCHECK_EQ(toScriptWrappable(context->Global()),
67 toScriptWrappable(
68 context->Global()->GetPrototype().As<v8::Object>()));
69 m_globalProxy.get().SetWrapperClassId(0);
70 }
71 V8DOMWrapper::clearNativeInfo(isolate(), context->Global());
72 m_scriptState->detachGlobalObject();
73 }
74
75 m_scriptState->disposePerContextData();
76
77 // It's likely that disposing the context has created a lot of
78 // garbage. Notify V8 about this so it'll have a chance of cleaning
79 // it up when idle.
80 V8GCForContextDispose::instance().notifyContextDisposed(
81 frame()->isMainFrame());
82
83 DCHECK(m_lifecycle == Lifecycle::ContextInitialized);
84 m_lifecycle = Lifecycle::ContextDetached;
89 } 85 }
90 86
91 void RemoteWindowProxy::initialize() { 87 void RemoteWindowProxy::initialize() {
92 TRACE_EVENT1("v8", "RemoteWindowProxy::initialize", "isMainWindow", 88 TRACE_EVENT1("v8", "RemoteWindowProxy::initialize", "isMainWindow",
93 frame()->isMainFrame()); 89 frame()->isMainFrame());
94 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( 90 SCOPED_BLINK_UMA_HISTOGRAM_TIMER(
95 frame()->isMainFrame() ? "Blink.Binding.InitializeMainWindowProxy" 91 frame()->isMainFrame() ? "Blink.Binding.InitializeMainWindowProxy"
96 : "Blink.Binding.InitializeNonMainWindowProxy"); 92 : "Blink.Binding.InitializeNonMainWindowProxy");
97 93
98 ScriptForbiddenScope::AllowUserAgentScript allowScript; 94 ScriptForbiddenScope::AllowUserAgentScript allowScript;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 165
170 // The named properties object of Window interface. 166 // The named properties object of Window interface.
171 v8::Local<v8::Object> windowProperties = 167 v8::Local<v8::Object> windowProperties =
172 windowPrototype->GetPrototype().As<v8::Object>(); 168 windowPrototype->GetPrototype().As<v8::Object>();
173 CHECK(!windowProperties.IsEmpty()); 169 CHECK(!windowProperties.IsEmpty());
174 V8DOMWrapper::setNativeInfo(isolate(), windowProperties, wrapperTypeInfo, 170 V8DOMWrapper::setNativeInfo(isolate(), windowProperties, wrapperTypeInfo,
175 window); 171 window);
176 } 172 }
177 173
178 } // namespace blink 174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698