From: Cheng Zhao Date: Wed, 24 Jun 2015 08:54:20 +0000 (+0800) Subject: Add Values() method for IDWeakMap X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28d1fb8cad11e4de01da572277cf806f902c9490;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Add Values() method for IDWeakMap --- diff --git a/atom/common/id_weak_map.cc b/atom/common/id_weak_map.cc index 4b653ca..fc5fa13 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 ce1a9a1..b16334d 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);