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

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

Issue 1133713008: [WIP] Migrate hasPendingActivity from ActiveDOMObject to ScriptWrappable. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review Comments Created 5 years, 2 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 13 matching lines...) Expand all
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 "config.h" 31 #include "config.h"
32 #include "bindings/core/v8/V8GCController.h" 32 #include "bindings/core/v8/V8GCController.h"
33 33
34 #include "bindings/core/v8/NPV8Object.h"
34 #include "bindings/core/v8/RetainedDOMInfo.h" 35 #include "bindings/core/v8/RetainedDOMInfo.h"
35 #include "bindings/core/v8/V8AbstractEventListener.h" 36 #include "bindings/core/v8/V8AbstractEventListener.h"
36 #include "bindings/core/v8/V8Binding.h" 37 #include "bindings/core/v8/V8Binding.h"
37 #include "bindings/core/v8/V8MutationObserver.h" 38 #include "bindings/core/v8/V8MutationObserver.h"
38 #include "bindings/core/v8/V8Node.h" 39 #include "bindings/core/v8/V8Node.h"
39 #include "bindings/core/v8/V8ScriptRunner.h" 40 #include "bindings/core/v8/V8ScriptRunner.h"
40 #include "bindings/core/v8/WrapperTypeInfo.h" 41 #include "bindings/core/v8/WrapperTypeInfo.h"
41 #include "core/dom/Attr.h" 42 #include "core/dom/Attr.h"
42 #include "core/dom/Document.h" 43 #include "core/dom/Document.h"
43 #include "core/dom/NodeTraversal.h" 44 #include "core/dom/NodeTraversal.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); 139 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value));
139 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); 140 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
140 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); 141 ASSERT(V8Node::hasInstance(wrapper, m_isolate));
141 Node* node = V8Node::toImpl(wrapper); 142 Node* node = V8Node::toImpl(wrapper);
142 // A minor DOM GC can handle only node wrappers in the main world. 143 // A minor DOM GC can handle only node wrappers in the main world.
143 // Note that node->wrapper().IsEmpty() returns true for nodes that 144 // Note that node->wrapper().IsEmpty() returns true for nodes that
144 // do not have wrappers in the main world. 145 // do not have wrappers in the main world.
145 if (node->containsWrapper()) { 146 if (node->containsWrapper()) {
146 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); 147 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
147 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(wrapper); 148 if (type != npObjectTypeInfo() && toScriptWrappable(wrapper)->hasPen dingActivity())
148 if (activeDOMObject && activeDOMObject->hasPendingActivity())
149 return; 149 return;
150 // FIXME: Remove the special handling for image elements. 150 // FIXME: Remove the special handling for image elements.
151 // The same special handling is in V8GCController::opaqueRootForGC() . 151 // The same special handling is in V8GCController::opaqueRootForGC() .
152 // Maybe should image elements be active DOM nodes? 152 // Maybe should image elements be active DOM nodes?
153 // See https://code.google.com/p/chromium/issues/detail?id=164882 153 // See https://code.google.com/p/chromium/issues/detail?id=164882
154 if (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendin gActivity()) 154 if (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendin gActivity())
155 return; 155 return;
156 // FIXME: Remove the special handling for SVG elements. 156 // FIXME: Remove the special handling for SVG elements.
157 // We currently can't collect SVG Elements from minor gc, as we have 157 // We currently can't collect SVG Elements from minor gc, as we have
158 // strong references from SVG property tear-offs keeping context SVG element alive. 158 // strong references from SVG property tear-offs keeping context SVG element alive.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId) 265 if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInf o::ObjectClassId)
266 return; 266 return;
267 267
268 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); 268 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value));
269 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); 269 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
270 270
271 if (value->IsIndependent()) 271 if (value->IsIndependent())
272 return; 272 return;
273 273
274 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); 274 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
275 275 if (type != npObjectTypeInfo() && toScriptWrappable(wrapper)->hasPending Activity()) {
276 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(wrapper);
277 if (activeDOMObject && activeDOMObject->hasPendingActivity()) {
278 m_isolate->SetObjectGroupId(*value, liveRootId()); 276 m_isolate->SetObjectGroupId(*value, liveRootId());
279 ++m_domObjectsWithPendingActivity; 277 ++m_domObjectsWithPendingActivity;
280 } 278 }
281 279
282 if (classId == WrapperTypeInfo::NodeClassId) { 280 if (classId == WrapperTypeInfo::NodeClassId) {
283 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); 281 ASSERT(V8Node::hasInstance(wrapper, m_isolate));
284 Node* node = V8Node::toImpl(wrapper); 282 Node* node = V8Node::toImpl(wrapper);
285 if (node->hasEventListeners()) 283 if (node->hasEventListeners())
286 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); 284 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value));
287 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); 285 Node* root = V8GCController::opaqueRootForGC(m_isolate, node);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 Visitor* m_visitor; 539 Visitor* m_visitor;
542 }; 540 };
543 541
544 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) 542 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor)
545 { 543 {
546 DOMWrapperTracer tracer(visitor); 544 DOMWrapperTracer tracer(visitor);
547 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); 545 v8::V8::VisitHandlesWithClassIds(isolate, &tracer);
548 } 546 }
549 547
550 } // namespace blink 548 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698