[api] Allow label annotations for PersistentValueMapBase
Allows adding a label to strong retainers in PersistentValueMapBase and its subclasses. These labels show up in DevTools and enable identifying strong retainers of objects. R: ulan@chromium.org Change-Id: Id5e19507c40e44688c82a4caec89449b563a0e8b Reviewed-on: https://chromium-review.googlesource.com/c/1372069 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#58177}
This commit is contained in:
parent
1ff10bf236
commit
81060c32da
@ -287,7 +287,10 @@ class PersistentValueMapBase {
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit PersistentValueMapBase(Isolate* isolate) : isolate_(isolate) {}
|
||||
explicit PersistentValueMapBase(Isolate* isolate)
|
||||
: isolate_(isolate), label_(nullptr) {}
|
||||
PersistentValueMapBase(Isolate* isolate, const char* label)
|
||||
: isolate_(isolate), label_(label) {}
|
||||
|
||||
~PersistentValueMapBase() { Clear(); }
|
||||
|
||||
@ -329,6 +332,10 @@ class PersistentValueMapBase {
|
||||
p.Reset();
|
||||
}
|
||||
|
||||
void AnnotateStrongRetainer(Global<V>* persistent) {
|
||||
persistent->AnnotateStrongRetainer(label_);
|
||||
}
|
||||
|
||||
private:
|
||||
PersistentValueMapBase(PersistentValueMapBase&);
|
||||
void operator=(PersistentValueMapBase&);
|
||||
@ -345,6 +352,7 @@ class PersistentValueMapBase {
|
||||
|
||||
Isolate* isolate_;
|
||||
typename Traits::Impl impl_;
|
||||
const char* label_;
|
||||
};
|
||||
|
||||
|
||||
@ -353,6 +361,8 @@ class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
||||
public:
|
||||
explicit PersistentValueMap(Isolate* isolate)
|
||||
: PersistentValueMapBase<K, V, Traits>(isolate) {}
|
||||
PersistentValueMap(Isolate* isolate, const char* label)
|
||||
: PersistentValueMapBase<K, V, Traits>(isolate, label) {}
|
||||
|
||||
typedef
|
||||
typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference
|
||||
@ -380,7 +390,9 @@ class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
||||
* by the Traits class.
|
||||
*/
|
||||
Global<V> SetUnique(const K& key, Global<V>* persistent) {
|
||||
if (Traits::kCallbackType != kNotWeak) {
|
||||
if (Traits::kCallbackType == kNotWeak) {
|
||||
this->AnnotateStrongRetainer(persistent);
|
||||
} else {
|
||||
WeakCallbackType callback_type =
|
||||
Traits::kCallbackType == kWeakWithInternalFields
|
||||
? WeakCallbackType::kInternalFields
|
||||
@ -425,6 +437,8 @@ class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
|
||||
public:
|
||||
explicit GlobalValueMap(Isolate* isolate)
|
||||
: PersistentValueMapBase<K, V, Traits>(isolate) {}
|
||||
GlobalValueMap(Isolate* isolate, const char* label)
|
||||
: PersistentValueMapBase<K, V, Traits>(isolate, label) {}
|
||||
|
||||
typedef
|
||||
typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference
|
||||
@ -452,7 +466,9 @@ class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
|
||||
* by the Traits class.
|
||||
*/
|
||||
Global<V> SetUnique(const K& key, Global<V>* persistent) {
|
||||
if (Traits::kCallbackType != kNotWeak) {
|
||||
if (Traits::kCallbackType == kNotWeak) {
|
||||
this->AnnotateStrongRetainer(persistent);
|
||||
} else {
|
||||
WeakCallbackType callback_type =
|
||||
Traits::kCallbackType == kWeakWithInternalFields
|
||||
? WeakCallbackType::kInternalFields
|
||||
|
Loading…
Reference in New Issue
Block a user