Remove IDWeakMap

This commit is contained in:
Cheng Zhao 2016-05-11 15:51:22 +09:00
parent ea93553225
commit c708ae8eb5
5 changed files with 12 additions and 67 deletions

View file

@ -8,7 +8,7 @@
#include <vector>
#include "atom/browser/api/event_emitter.h"
#include "atom/common/id_weak_map.h"
#include "atom/common/key_weak_map.h"
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@ -113,21 +113,26 @@ class TrackableObject : public TrackableObjectBase,
void AfterInit(v8::Isolate* isolate) override {
if (!weak_map_) {
weak_map_.reset(new atom::IDWeakMap);
weak_map_.reset(new atom::KeyWeakMap<int32_t>);
}
weak_map_id_ = weak_map_->Add(isolate, Wrappable<T>::GetWrapper());
weak_map_id_ = ++next_id_;
weak_map_->Set(isolate, weak_map_id_, Wrappable<T>::GetWrapper());
if (wrapped_)
AttachAsUserData(wrapped_);
}
private:
static scoped_ptr<atom::IDWeakMap> weak_map_;
static int32_t next_id_;
static scoped_ptr<atom::KeyWeakMap<int32_t>> weak_map_;
DISALLOW_COPY_AND_ASSIGN(TrackableObject);
};
template<typename T>
scoped_ptr<atom::IDWeakMap> TrackableObject<T>::weak_map_;
int32_t TrackableObject<T>::next_id_ = 0;
template<typename T>
scoped_ptr<atom::KeyWeakMap<int32_t>> TrackableObject<T>::weak_map_;
} // namespace mate