diff --git a/atom/common/id_weak_map.cc b/atom/common/id_weak_map.cc index 4b653cafee30..fc5fa13a43eb 100644 --- a/atom/common/id_weak_map.cc +++ b/atom/common/id_weak_map.cc @@ -47,6 +47,14 @@ std::vector IDWeakMap::Keys() const { return keys; } +std::vector> IDWeakMap::Values(v8::Isolate* isolate) { + std::vector> keys; + keys.reserve(map_.size()); + for (const auto& iter : map_) + keys.emplace_back(v8::Local::New(isolate, *iter.second)); + return keys; +} + void IDWeakMap::Remove(int32_t id) { auto iter = map_.find(id); if (iter == map_.end()) diff --git a/atom/common/id_weak_map.h b/atom/common/id_weak_map.h index ce1a9a128798..b16334d6cea1 100644 --- a/atom/common/id_weak_map.h +++ b/atom/common/id_weak_map.h @@ -31,6 +31,9 @@ class IDWeakMap { // Returns IDs of all available objects. std::vector Keys() const; + // Returns all objects. + std::vector> Values(v8::Isolate* isolate); + // Remove object with |id| in the WeakMap. void Remove(int32_t key);