refactor: remove the RenderFrameFunctionStore and use privates to memory manage (#23592)

This commit is contained in:
Samuel Attard 2020-05-15 11:57:40 -07:00 committed by GitHub
parent 3cf97d5717
commit 9d7ba98209
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 166 additions and 261 deletions

View file

@ -112,6 +112,29 @@ bool IsSameOrigin(const GURL& l, const GURL& r) {
return url::Origin::Create(l).IsSameOriginWith(url::Origin::Create(r));
}
#ifdef DCHECK_IS_ON
std::vector<v8::Global<v8::Value>> weakly_tracked_values;
void WeaklyTrackValue(v8::Isolate* isolate, v8::Local<v8::Value> value) {
v8::Global<v8::Value> global_value(isolate, value);
global_value.SetWeak();
weakly_tracked_values.push_back(std::move(global_value));
}
void ClearWeaklyTrackedValues() {
weakly_tracked_values.clear();
}
std::vector<v8::Local<v8::Value>> GetWeaklyTrackedValues(v8::Isolate* isolate) {
std::vector<v8::Local<v8::Value>> locals;
for (size_t i = 0; i < weakly_tracked_values.size(); i++) {
if (!weakly_tracked_values[i].IsEmpty())
locals.push_back(weakly_tracked_values[i].Get(isolate));
}
return locals;
}
#endif
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
@ -136,6 +159,11 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("requestGarbageCollectionForTesting",
&RequestGarbageCollectionForTesting);
dict.SetMethod("isSameOrigin", &IsSameOrigin);
#ifdef DCHECK_IS_ON
dict.SetMethod("getWeaklyTrackedValues", &GetWeaklyTrackedValues);
dict.SetMethod("clearWeaklyTrackedValues", &ClearWeaklyTrackedValues);
dict.SetMethod("weaklyTrackValue", &WeaklyTrackValue);
#endif
}
} // namespace