Skip to content

Commit 6a52868

Browse files
committed
chore: Get inspector local context using Persistent.Get()
This is the only remaining usage of PersistentToLocal. We don't need its capability of dealing with weak persistent references because we never call SetWeak on the context.
1 parent c8df6e3 commit 6a52868

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

test-app/runtime/src/main/cpp/JsV8InspectorClient.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ void JsV8InspectorClient::quitMessageLoopOnPause() {
139139
}
140140

141141
v8::Local<v8::Context> JsV8InspectorClient::ensureDefaultContextInGroup(int contextGroupId) {
142-
v8::Local<v8::Context> context = PersistentToLocal(isolate_, context_);
143-
return context;
142+
return context_.Get(isolate_);
144143
}
145144

146145
void JsV8InspectorClient::doDispatchMessage(const std::string& message) {
@@ -172,25 +171,6 @@ void JsV8InspectorClient::sendNotification(std::unique_ptr<StringBuffer> message
172171
void JsV8InspectorClient::flushProtocolNotifications() {
173172
}
174173

175-
template<class TypeName>
176-
inline v8::Local<TypeName> StrongPersistentToLocal(const v8::Persistent<TypeName>& persistent) {
177-
return *reinterpret_cast<v8::Local<TypeName> *>(const_cast<v8::Persistent<TypeName> *>(&persistent));
178-
}
179-
180-
template<class TypeName>
181-
inline v8::Local<TypeName> WeakPersistentToLocal(v8::Isolate* isolate, const v8::Persistent<TypeName>& persistent) {
182-
return v8::Local<TypeName>::New(isolate, persistent);
183-
}
184-
185-
template<class TypeName>
186-
inline v8::Local<TypeName> JsV8InspectorClient::PersistentToLocal(v8::Isolate* isolate, const v8::Persistent<TypeName>& persistent) {
187-
if (persistent.IsWeak()) {
188-
return WeakPersistentToLocal(isolate, persistent);
189-
} else {
190-
return StrongPersistentToLocal(persistent);
191-
}
192-
}
193-
194174
void JsV8InspectorClient::init() {
195175
if (inspector_ != nullptr) {
196176
return;

test-app/runtime/src/main/cpp/JsV8InspectorClient.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ class JsV8InspectorClient : V8InspectorClient, v8_inspector::V8Inspector::Channe
1616
public:
1717
static JsV8InspectorClient* GetInstance();
1818

19-
template <class TypeName>
20-
static v8::Local<TypeName> PersistentToLocal(v8::Isolate* isolate, const v8::Persistent<TypeName>& persistent);
21-
2219
void init();
2320
void connect(jobject connection);
2421
void scheduleBreak();

0 commit comments

Comments
 (0)