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

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

Issue 1805843002: [v8 gc] Introduce a base class for all objects that can have pending activity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp b/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
index 0555700c15faa1556e0d996ca38546046b6ae55f..389756e6f31c8b9fc6c3dfe3dbbadb506d87786e 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
@@ -30,6 +30,7 @@
#include "bindings/core/v8/V8GCController.h"
+#include "bindings/core/v8/ActiveScriptWrappable.h"
#include "bindings/core/v8/NPV8Object.h"
#include "bindings/core/v8/RetainedDOMInfo.h"
#include "bindings/core/v8/V8AbstractEventListener.h"
@@ -119,7 +120,7 @@ public:
v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8::Persistent<v8::Object>::Cast(*value));
ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
- if (type != npObjectTypeInfo() && toScriptWrappable(wrapper)->hasPendingActivity()) {
+ if (type != npObjectTypeInfo() && type->hasPendingActivity(wrapper)) {
v8::Persistent<v8::Object>::Cast(*value).MarkActive();
return;
}
@@ -164,7 +165,7 @@ public:
ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
- if (type != npObjectTypeInfo() && toScriptWrappable(wrapper)->hasPendingActivity()) {
+ if (type != npObjectTypeInfo() && type->hasPendingActivity(wrapper)) {
// If you hit this assert, you'll need to add a [DependentiLifetime]
// extended attribute to the DOM interface. A DOM interface that
// overrides hasPendingActivity must be marked as [DependentiLifetime].
@@ -436,8 +437,9 @@ void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor)
class PendingActivityVisitor : public v8::PersistentHandleVisitor {
public:
- explicit PendingActivityVisitor(ExecutionContext* executionContext)
- : m_executionContext(executionContext)
+ PendingActivityVisitor(v8::Isolate* isolate, ExecutionContext* executionContext)
+ : m_isolate(isolate)
+ , m_executionContext(executionContext)
, m_pendingActivityFound(false)
{
}
@@ -452,11 +454,12 @@ public:
if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInfo::ObjectClassId)
return;
- const v8::Persistent<v8::Object>& wrapper = v8::Persistent<v8::Object>::Cast(*value);
+ v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8::Persistent<v8::Object>::Cast(*value));
+ ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
// The ExecutionContext check is heavy, so it should be done at the last.
if (type != npObjectTypeInfo()
- && toScriptWrappable(wrapper)->hasPendingActivity()
+ && type->hasPendingActivity(wrapper)
// TODO(haraken): Currently we don't have a way to get a creation
// context from a wrapper. We should implement the way and enable
// the following condition.
@@ -476,11 +479,12 @@ public:
bool pendingActivityFound() const { return m_pendingActivityFound; }
private:
+ v8::Isolate* m_isolate;
RawPtrWillBePersistent<ExecutionContext> m_executionContext;
bool m_pendingActivityFound;
};
-bool V8GCController::hasPendingActivity(ExecutionContext* executionContext)
+bool V8GCController::hasPendingActivity(v8::Isolate* isolate, ExecutionContext* executionContext)
{
// V8GCController::hasPendingActivity is used only when a worker checks if
// the worker contains any wrapper that has pending activities.
@@ -488,7 +492,8 @@ bool V8GCController::hasPendingActivity(ExecutionContext* executionContext)
DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHistogram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 50));
double startTime = WTF::currentTimeMS();
- PendingActivityVisitor visitor(executionContext);
+ v8::HandleScope scope(isolate);
+ PendingActivityVisitor visitor(isolate, executionContext);
toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor);
scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - startTime));
return visitor.pendingActivityFound();

Powered by Google App Engine
This is Rietveld 408576698